[Prev][Next][Index][Thread]
Re: Need help with Class-Allocated Slots
When I first looked a Perl, I was not impressed. I have since been
compelled to use it extensively. It is the antithesis of "elegant", but
I have found that I can get things done, usually in a fairly clear way,
because they provide an intuitive syntax for a lot of what I do.
I'm not trying to be an advocate for the Perl approach, I simply would
not feel violated if Dylan provided an inelegant feature (inelegant at
some level, maybe elegant at another level) for my convenience.
Lisp is pristine, but many programmers don't like it for just that
reason. If pristine was the measure, Dylan could have stayed with the
prefix syntax too. I would prefer convenient in this case over
pristine.
> > "Scott McKay" <swm@mediaone.net> writes:
> >
> > > During the design of Dylan, I proposed that class slots be accessible
> > > by calling the accessor on the class object itself, but Moon didn't
> > > like
> > > it because it confuses class vs. instance. I agree with Moon on the
> > > exact point, but I still think that the semantics of my dumb-ass
> > > proposal
> > > are well enough understood, that it is probably reasonable.
> >
> > Maybe it's time to resurrect the Dylan Language discussion at
> >
> > http://www.isr.com/dylan/dylan-language/
> >
> > I agree that it should be possible to access class slots without
> > having an instance.
> >
> > Andreas
>
>
> I'm actually surprised this is even being considered. The idea that
> class slots belong to the class itself is incorrect, though widely held.
>
> Each class is an instance of <class>. Conceptually, the lines
>
> -------------------------------------
> <my-class>.my-class-slot;
> my-class-slot-getter (<my-class>);
> -------------------------------------
>
> imply that <my-class> has a slot called my-class-slot. But it doesn't!
> <my-class> is an instance of <class>, not a sub-class of <class>. The
> only slots that <my-class> has are the slots that <class> has, and
> <class> does not have the my-class-slot slot (...umm...yeah...).
>
> Do y'all really want to muddy up Dylan's pristine conceptual waters like
> that? (It really is much more pristine in my head than in English.)
>
> Of course, it is certainly possible. You could write an getter that
> specializes on a particular instance of the class, like so:
>
> -------------------------------------
> define method my-class-slot-getter (an-instance :: <class> == <my-class>)
> an-instance.my-class-slot;
> end;
> -------------------------------------
>
> But I'd rather have the pristine waters, thank you.
>
> It's really the same principle as Dylan's singletons. You can make as
> many instances of a singleton as you like. It's just that all those
> instances refer to the same object. Similarly, you can make as many
> instances of a class slot as you like, they just all refer to the same
> object.
>
> Thank you, and good night...
>
Follow-Ups:
References: