very basic listbox code request for comments
Brian Rice
water at tunes.org
Tue May 16 13:01:52 PDT 2006
On May 16, 2006, at 12:10 PM, Timmy Douglas wrote:
> Brian Rice <water at tunes.org> writes:
>> On May 14, 2006, at 12:46 PM, Timmy Douglas wrote:
>>> Brian Rice <water at tunes.org> writes:
>>> But this part of it doesn't make sense root.slate (L525):
>>>
>>> x@(Root traits) addDynamicSlot: slotName valued: val
>>> "This creates a `dynamic slot', which means an immutable delegated
>>> slot
>>> that can be overridden from its default per object, making an
>>> effective
>>> customization policy.
>>> It works by ensuring that the object has a slot of that name with
>>> that value,
>>> and finally defining a mutator method on it to define a new slot on
>>> the
>>> *receiver* when mutations are attempted."
>>> [
>>> x addImmutableSlot: slotName valued: val.
>>>
>>>
>>> " why not addImmutableDelegate? "
>>
>> Do you want to delegate to the value 4 when you merely want it to be
>> an overrideable default value? There's no case I can think of where
>> you'd want to override a delegation dynamically using a mutator
>> method.
>
> Where did 4 come from?
It was just an example of an object you'd put in a slot that you'd
rather not delegate to (read: inherit from). MOST objects are unsafe
to delegate to from a given one. Delegation slots are Slate's most
powerful and dangerous feature (and I welcome safer yet powerful
alternatives).
>> Changing delegation dynamically is too powerful and should only be
>> done when it's been thought through in a pattern (such as the
>> Morphic dynamic mixins code).
>
> I think this behavior sort of makes sense with users manually
> overriding defaults in the themes here. Then, to change the default
> color (etc) you just modify one value (in the top class), and since
> the non-overriden objects all point to it, you don't have to do any
> propagation down the line. To restore the default setting, you just
> remove the slot in your object you overrode it in, and it points back
> to the default.
I think you don't understand what what your change does. Let me explain:
When you use #addImmutableDelegate:valued: in that code, you make the
HOLDER of the new slot inherit from the VALUE you're putting in that
overridable slot. In this paragraph, however, you're talking about
wanting to delegate from some other object to the HOLDER of the slot,
and this is what #addDynamicSlot:valued: is for.
These are two totally separate concepts that you're confusing; you
want the latter, but have implemented the former.
>>> [| :obj :val | obj addSlot: slotName valued: val]
>>> asMethod: (x mutatorNameFor: slotName)
>>> on: {x. NoRole}.
>>> x
>>> ].
>>
>>> When I tried copying and pasting that code and making the change in
>>> theme.slate, then loading it, but I got weird errors later in
>>> ui.slate
>>> where:
>>
>> Why did you have to load that code into Slate when you made no change
>> to it and it is already in the standard image?
>
> I tried changing the 'slot' part to delegate..
Uh, don't? Let me rephrase that: DON'T do that. :) I mean that in the
most helpful way: delegation slots are for inheritance, and you need
to think about the inheritance graph if you decide to mess with it.
You want to inherit from one object to another, and the slot is part
of what you get from that inheritance, but you don't want the
inheriting object to effectively BECOME the value by inheriting from
the value, you want to inherit from the object that holds that value
via a label and then override the label with a new value in the new
object.
>> I need something more concrete that I can debug - a smaller, tighter
>> test case.
>
> this is my first time using darcs, I tried sending you a patch using
> it. hopefully it works... here is what I'm doing here:
Yeah, I think I see why this is happening now. You're delegating to
(and therefore inheriting from) the floating-point value that you
want as an attribute. This is BAD. Please stop hurting yourself. :)
> timmy at main ~/src/slate/slate/main $ ./vm -i slate.image
> Slate: Growing heap to 7790120 bytes.
> Nil
> Slate 1> ExternalMethod.
> lobby ensureNamespace: #Graphics &delegate: True.
> load: 'src/ui/region.slate'.
> load: 'src/ui/transform.slate'.
...
> Nil
> Slate 13> lobby define: #ListboxElement &parents:
> {SelectionThemeElement. TextThemeElement}.
> 1.058791e-22
> Slate 14>
--
-Brian
http://tunes.org/~water/brice.vcf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/slate/attachments/20060516/3764bd7e/PGP.pgp
More information about the Slate
mailing list