[Prev][Next][Index][Thread]
Re: [Q]Why are all classes rooted by <object>
Brad Settlemyer wrote:
> Well, the subject pretty much says it all, but can anyone explain the
> rationale behind making all classes implicitly derived from <object>.
>
> Dylan appears to me to be suitably generic not to need this artifice (Java,
> for example, is not). What am I missing?
That it is quite important to be able to declare
methods that can operate on *any* object a program
will use.
define generic xml-encode (obj :: <object>) => (xml :: <string>);
define generic write
(stream :: <stream>, obj :: <object>)
=> (str :: <stream>);
define generic \= (obj1, obj2) => (equal? :: <boolean>);
(here <object> is only used implicitly, but it is still used)
Without a unique root it would be quite difficult to get such
functions to work. You could then argue that this root does not
need an explicit name, but then giving it a name has no drawback
I can see.
It may not be the whole story and I hope others will complete it,
but IMO that may be the most important aspect.
Regards - Eric
Follow-Ups:
References: