Prevent cloning of clones
Adde
adde at trialcode.com
Wed Apr 27 01:22:26 PDT 2005
Brian Rice wrote:
> On Apr 26, 2005, at 1:54 PM, Brian Rice wrote:
>
>> On Apr 26, 2005, at 1:37 PM, Adde wrote:
>>
>>> It's highly likely that this is just me programming
>>> over-defensively. I've spent a considerable part of my life trying
>>> to please C++.
>>> But, I feel that the only Units that should be used with toXML are
>>> Units for which someone has specified an XML representation
>>> (overridden toXML). Lengths counts as SVG units the second someone
>>> specifies how a Length should be formatted in in an SVG Document.
>>> This feels like a problem that's bound to come up again, that you
>>> wan't to add special formatting to specific kinds of Units (instead
>>> of adding it to BaseUnit).
>>> I fully agree that the Pixel unit probably belongs in some kind of
>>> Graphics namespace, though.
>>
>>
>> Fair enough. I can add Length/other-dimension subtypings for the
>> various kinds of units for dispatch hooks.
>
>
> I'm going to delay adding this yet, as I'm not sure if it'd work fine
> in the obvious manner, although there is already TemperatureUnit
> distinguished from other types. It'll probably happen soon.
I can see where it could be useful to have a hierarchy to enable you to
override behaviour for entire subtrees of Units. In this case I'm
probably better of overriding individually for each of the units I'm
interested in (cm, mm, em and px) though.
What I wan't to do is overriding formatting behaviour for UnitValues
having specific Units.
As I understand it the only way to dispatch formatting of a UnitValue on
it's Unit is by overriding the creation of UnitValues for that specific
Unit and then dispatching on the type of UnitValue as ususal. Am I
missing something? Is it possible to dispatch on slots of an object?
One way to make it easier would be if each Unit contained a slot with
it's own UnitValue that is cloned when creating values, then you could
dispatch on it like this:
uv@(Pixel baseValue) toXML [
(uv value toXML) ; (uv unit abbrev toXML)
].
>> On a related note, the with: message is supposed to work with
>> arbitrary objects (e.g. "4 with: lobby" should turn into "4
>> lobbies"), and doesn't, so I'll fix that while my mind is on it as well.
>
>
> This is done, although I backed away from the printout style. I also
> renamed with: to of: since it reads better (and we have other
> selectors with with: keywords). Now it'll do "4 of: Namespace" for "4
> of: lobby" - it's not terribly good, just counting things that satisfy
> isSameAs: but that can be parametrized. I'm sure I won't hear about
> this feature for a few months at least, though.
>
of: is definitely better than with:.
> --
> Brian T. Rice
> LOGOS Research and Development
> http://tunes.org/~water/
>
/Adde
More information about the Slate
mailing list