[Openmcl-devel] constant string values
gb at clozure.com
Mon Feb 14 00:51:23 UTC 2005
On Sun, 13 Feb 2005, alex crain wrote:
> Is there any way to define a new NSString constant?
> I know that I can use #@"OpenMCLPboardType" but
> I'd like to have #?OpenMCLPboardType for consistancy.
#@"foo" does define a constant NSString. It doesn't define a
foreign variable whose value is that constant string.
In a lot of cases, Cocoa documentation doesn't define the value
of strings that are used to name attributes; it does define the
name of an ObjC variable whose value is a (constant) NSString.
Even if you "know" what the string contains, it's probably wiser
to do the indirection and reference the variable, since the
value may change in the future or be sensitive to localization
If the application is defining a new attribute (a new pasteboard
type), there seem to be fewer reasons for wanting to store that
in a foreign variable (and use @? to access the variable's value.)
> I'm thinking that the answer is "no", short of creating and
> loading a special shared library with a single object and
> I don't want it that badly.
You would have to do something like that in order for foreign
code to be able to import a reference to the foreign variable.
You might be able to do something far cheaper to persuade #?foo
to do something - other than error - if it can't find a foreign
symbol named _foo.
> Still, it never hurts to ask.
In most programming languages, it isn't possible to "define a
new global variable" at runtime; I'm not familiar with any
dynamic linker technology that would allow us to (simply and
conveniently) export a symbol at runtime and cause foreign
code to notice that a new symbol was available ...
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel