[Jprogramming] 18!:4 documentation
Miller, Raul D
rdmiller at usatoday.com
Mon Feb 13 09:55:37 HKT 2006
Henry Rich wrote:
> My recollection of 18!:4 is that I got burned when I put
> 18!:4 in my programs directly, because the locale of the
> calling verb got changed. I concluded that it was
> intended to be used by name, i. e.
> setlocale =: 18!:4
> The documentation you cite confirms this.
Ok, thanks, that untangled my thinking:
Locales affect tacit and explicit verbs the same way.
All that matters is the verb be named.
When you have a call stack like this:
Verb1 calls 18!:4
Verb2 calls Verb1
Verb3 calls Verb2
The locale of Verb2 is changed. The locales of Verb1 and of
Verb3 are not changed.
I'm still feeling my way through these issues, but this seems
to be correct. Each name is associated with a locale, even
though most of the time the association is implicit, and
most of the time the locale is base.
But this means that the definition of coclass is... odd.
coclass_z_=: 3 : 0
y=. <,> y.
18!:4 y
if. 0 ~: 4!:0 <'COCLASSPATH__y' do.
COCLASSPATH=: y,<,'z'
end.
)
If I execute the statement
coclass 'c1'
This might or might not have the effect of
COCLASSPATH_base_=:;:'c1 z'
If prior locale was not base, the assignment would take place in
another locale. If COCLASSPATH already existed in base or that
other locale (whichever is relevant), no assignment takes place.
If the class is being redefined then COCLASSPATH value is not set,
regardless of whether it exists in the prior locale.
Since this effect is hard to understand and cannot be relied on in a
number of common cases, I think the assignment shouldn't happen
at all.
Another question I'm struggling with is: why do we use COCLASSPATH
at all? Why is 18!:1 evaluated in the class's locale not used
by conew when initializing objects? This would mean that coinsert
'classname' would do the right thing automatically, wouldn't it?
--
Raul
More information about the Programming
mailing list