
-----------------------------------
TheOneTrueGod
Sun May 21, 2006 10:11 pm

Importing inherited classes
-----------------------------------
If I have a lot of objects, all of which are interconnected by inheritance, is there any easy way to import them all?

Eg:


class Spell
end Spell

class Projectile
   inherit Spell
end Projectile
class Fireball
   inherit Projectile
end Fireball

class Explosion
   inherit Spell
end Explosion
%... You get the idea


class Unit
import Explosion, Fireball, Spell,...%See Notes below
end Unit


I've tried packaging them all into a module, and then importing that module, but then I get the error:

"Fireball" is read-only in this scope and cannot be 'new'ed

(This is in the situation where I have a flexible array of Spells, and I try creating a new element referencing Fireball...)

-----------------------------------
Cervantes
Mon May 22, 2006 8:11 am


-----------------------------------
Just include them all. Don't make them into a Turing unit.

-----------------------------------
Delos
Mon May 22, 2006 12:00 pm

Re: Importing inherited classes
-----------------------------------

"Fireball" is read-only in this scope and cannot be 'new'ed

(This is in the situation where I have a flexible array of Spells, and I try creating a new element referencing Fireball...)

IIRC, this error msg is for show only...test it out by creating a new object as you did, then attempting to use it as you regularly would.  Methinks it will function quite regularly, despite its apparently uninitialized state.
Otherwise, go with what Cervantes has to say.
