[Prev][Next][Index][Thread]

Re: Dylan Features



in article 8mf8e8$a27$1@nnrp1.deja.com, oodl@my-deja.com at oodl@my-deja.com
wrote on 2000.08.04 13:18:

> In article <398ACAE5.45966287@lotus.com>,
> Enter your Notes name here <firstname_lastname@lotus.com> wrote:
>> I seem to remember that back in the old days, when Dylan had
>> Scheme-style syntax, that you could add slots to individual instances.
>> Can you do this in the current version of Dylan?
> 
> Yes, you can dispatch methods on singletons:

But you can't (trivially) add a slot to an object at runtime, which is what
I believe the original question was about.

I suppose you could implement (the illusion of) adding slots at runtime
using a <table>, e.g., something like:

define variable *a-runtime-slot* = make(<weak-table>);

define method a-runtime-slot (object) => (slot-value)
    *a-runtime-slot*[object]
end;

define method a-runtime-slot-setter (value, object) => (object)
    *a-runtime-slot*[object] := value;
end;

Oh, wait. Maybe that is trivial. Although this still requires the slot to be
defined at compile-time, which isn't as general as "adding slots to
individual instances" might imply.

-- 
Chris Page
Mac OS Guy
Palm, Inc.

let mailto = concatenate( "Chris Page <page", "@", "best.com>");





References: