From: Xavier Noria Date: 2012-12-04T08:23:51+09:00 Subject: Re: changing superclass --Apple-Mail-22FE072E-6135-4BBE-AD67-B8FF532F40DB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable The ancestry chain cannot be modified except for adding stuff in a restricte= d way. That is the way the language works, you cannot insert in arbitrary pl= aces, replace, reorder, or remove. There is no API. Language designers would know the rationale, I don't. Sent from my iPad On 3 Dec 2012, at 23:19, Nokan Emiro wrote: >> If Animal is the superclass of Dog, then why doesn't Animal's greet() >> method execute? >=20 > Because imported modules go right above the current class in the ancestors= > chain, but it does not mean that the imported module becomes a class: >=20 > >> Dog.superclass > =3D> Animal > >> Dog.ancestors > =3D> [Dog, Stuff, Animal, Object, Kernel, BasicObject] > >> Stuff.class > =3D> Module > =20 > The goal is something like this: >=20 > class A; end > class B; end > class C < A; end > C.superclass =3D B # this is wrong here! >=20 > This last line doesn't work, of course, but my question was how > to achieve something like that what it suggests... >=20 >=20 --Apple-Mail-22FE072E-6135-4BBE-AD67-B8FF532F40DB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
The ancestry chain cannot be modified except for adding stuff in a restricted way. That is the way the language works, you cannot insert in arbitrary places, replace, reorder, or remove. There is no API.

Language designers would know the rationale, I don't.

Sent from my iPad

On 3 Dec 2012, at 23:19, Nokan Emiro <uzleepito@gmail.com> wrote:

If Animal is the superclass of Dog, then why doesn't Animal's greet()
method execute?

Because imported modules go right above the current class in the ancestors
chain, but it does not mean that the imported module becomes a class:

>> Dog.superclass
 => Animal
>> Dog.ancestors
 => [Dog, Stuff, Animal, Object, Kernel, BasicObject]
>> Stuff.class
 => Module
 
The goal is something like this:

class A; end
class B; end
class C < A; end
C.superclass = B    # this is wrong here!

This last line doesn't work, of course, but my question was how
to achieve something like that what it suggests...


--Apple-Mail-22FE072E-6135-4BBE-AD67-B8FF532F40DB--