On Aug 23, 2005, at 10:03 PM, glenn andreas wrote:
So how would NSClassFromString handle having the classes being
renamed? You could, in theory, find the static strings and change
them (ugh), but anything which uses a string constructed on the fly
would fail (since the constructed name no longer matches).
true.
And this approach seems to have the insidious side effect that the
original code (that which existed before being rebranded) has no
way to know that this is happening (since there is that module that
takes the original classes and then actually does the rebranding).
Personally, I'd investigate a C++ style namespace (which would be
built on a prefixing scheme, rather than renaming, so
NSClassFromString could be modified to know the 'current' classname).
Well, prefixing the module name is what Modula-2 does by default and
in an all-ObjM2 project this would be simple. The trouble begins when
you start mixing ObjM2 and ObjC sources in the same project because
the ObjC compiler doesn't know about the prefixing of classes.
If the module name was FooLib and it contains a class FooClass, then
the ObjM2 compiler would generate a symbol such as
ObjM2_FooLib__FooClass. That class would then be referred to by ObjM2
sources as either FooLib.FooClass, if imported using "IMPORT FooLib"
or as FooClass, if imported using "FROM FooLib IMPORT FooClass".
Again, the ObjM2 compiler would know how to translate these
references back to the prefixed name.
Now, if you want to use a class written in ObjM2 from within ObjC
code, then you'd have to know the prefixing scheme and refer to the
class in its raw prefixed name, like ...
that's not really going to fly with ObjC developers is it?
Of course you can do ...
#define FooClass ObjM2_FooLib__FooClass
... and the ObjM2 compiler could even generate the FooClass.h header
file for ObjC accordingly including the macros, but this is not going
to help with strings which represent class names because the
preprocessor won't replace any occurences of FooClass inside a
string, or will it?!
Again, the ObjM2 compiler could insert a macro ...
#define CLASSNAME(x) "ObjM2_FooLib__" # x
... but this requires ObjC developers to use CLASSNAME(FooClass)
everywhere in the ObjC code where they would otherwise just use
"FooClass" which is much shorter, though in this case it would be
incorrect.
In other words, the whole exercise comes down to making things
seamless at the expense of easy implementation versus not having the
burden of a difficult implementation in return for less seamlessness.
So, the question is, how seamless does this have to be for the
majority of ObjC developers to accept the way in which they can
incorporate ObjM2 classes into their ObjC projects?
anyway, thanks for the feedback.
rgds
ObjM2 project
BTW, though Modula-2 wasn't the first language to use module based
namespaces -- Wirth got his inspiration for M2 from Mesa while at
Xerox Parc -- M2 was finalised in 1978 thus predates C++ by at least
5 years. So, prefix based namespaces are certainly not a C++ invention.
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden