Prevent cloning of clones

Adde adde at trialcode.com
Mon Apr 25 13:10:52 PDT 2005


Brian Rice wrote:

> First, try looking at src/lib/dimensioned.slate which has a full units 
> library. Also, use Oddball clone, which has this behavior that you 
> cannot clone it again. Then, have it delegate 
> (addImmutableDelegate:valued: or set what delegation slot it does 
> have) to the intended parent. Normally, we don't bother with that 
> level of control yet, though.
>
> On Apr 25, 2005, at 5:56 AM, Adde wrote:
>
>> I'm trying to create a representations for different units of 
>> measurement in SVG and the best i could come up with was the following:
>>
>> SVG addPrototype: #Unit derivedFrom: {Cloneable}.
>> SVG Unit addSlot: #postfix.
>> SVG Unit traits addSlot: #Pixels valued: (SVG Unit clone `>> 
>> [postfix: 'px'.]).
>> u@(SVG Unit traits) toXML [ u postfix ].
>>
>> However, there is no point in doing 'SVG Unit Pixels clone' so I was 
>> wondering how I can make it behave like numbers, ie. '1 clone' gives 
>> an error message.
>>
>> /Adde
>>
>>
> -- 
> Brian T. Rice
> LOGOS Research and Development
> http://tunes.org/~water/
>
Ok, this is what i've got so far:

SVG addPrototype: #Unit derivedFrom: {Cloneable}.
SVG Unit addSlot: #postfix.
SVG Unit addSlot: #Pixels valued: Oddball clone `>> 
[addImmutableDelegate: #super valued: SVG Unit clone `>> [postfix: 'px'.].].

u@(SVG Unit traits) toXML [ u postfix ].

I can still clone SVG Unit Pixels, though. I guess what it does is that 
it clones SVG Unit by delegating the clone call.
Feels like i'm running in circles here ;)

/Adde




More information about the Slate mailing list