Re: Jump tables and OOP in Oberon

Darius Blasband <darius@phidani.be>
23 Jul 1996 23:36:08 -0400

          From comp.compilers

Related articles
Jump tables and OOP in Oberon rmeenaks@bfm.com (1996-07-13)
Re: Jump tables and OOP in Oberon tim@xinotech.com (Tim Dwyer) (1996-07-18)
Re: Jump tables and OOP in Oberon bobduff@world.std.com (1996-07-22)
Re: Jump tables and OOP in Oberon paulh@harlequin.co.uk (1996-07-23)
Re: Jump tables and OOP in Oberon darius@phidani.be (Darius Blasband) (1996-07-23)
| List of all articles for this month |

From: Darius Blasband <darius@phidani.be>
Newsgroups: comp.compilers
Date: 23 Jul 1996 23:36:08 -0400
Organization: Phidani Software, Brussels
References: 96-07-083 96-07-119
Keywords: code

Ram Meenakshisundaram wrote:
>
> Also, Oberon has an IS statement that returns TRUE or FALSE if a variable
> is inheriated from a particular type. That is if variable x is of type C and
> type C is inherited by type A, then the following would return true:
>
> IS(x, A)
>
> How can this be implemented the most efficent way?


Tim Dwyer wrote:
> There was an article in ACM TOPLAS that gave a way to test whether the
> type of a variable is an extension of another type, without using a loop.
> It uses a little more storage than the method you describe.


Another way of achieveing this is to number your class inheritance tree in a
depth first fashion, in such a way that an interval can be defined for every
class. This interval defines signatures that are known to denote the class.
Any meta class with a signature within this interval is or is derived from
the class.


Given an instance, just follow the link to its metaclass, and check whether
its magic number lies within the interval of the class A.


This system is simple, requires constant time when testing, but does not
support convenient dynamic addition of new classes, since the numbering is
performed at system initialization time; while the scheme described in
TOPLAS did support dynamic addition of new classes.


In practice, this has seldom been a problem: renumbering the inheritance
tree is neglectible when compared to the actual addition of a new class to
the system.


Regards,


Darius


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.