#1665 How to make an abstract actor with param?

Xan Thu 6 Oct 2011

Hi,

Is it possible to make an abstract actor with parameter?

Like (in pseudocode):

abstract MyActor(Str string):Actor {

...

}

?

Thanks a lot, Xan.

brian Thu 6 Oct 2011

If I understand you correctly your code would look something like this:

abstract const class MyActor : Actor  
{
  new make(ActorPool pool, Str param) : super(pool)
  {
    this.param = param
  }
}

Xan Thu 6 Oct 2011

This:

using concurrent

abstract const class MyActor : Actor {

new make(ActorPool pool, Str param) : super(pool)
{
  this.param = param
}

}

if I name it: hola.fan gives me:

fan hola.fan /home/xan/proves/temporal/hola.fan(7,10): Unknown slot hola_0::MyActor.param ERROR: cannot compile script

What's wrongs.

Ah!, yes, you understood correctly.

Xan.

DanielFath Thu 6 Oct 2011

Try this Xan:

using concurrent

abstract const class MyActor : Actor {

  const Str param

  new make(ActorPool pool, Str param) : super(pool)
  {
    this.param = param
  }

}

Xan Fri 7 Oct 2011

Yes, it works. Thanks.

Login or Signup to reply.