Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Namespaces and ObjC




On Aug 23, 2005, at 5:15 PM, Timothy J. Wood wrote:

Given the dynamic runtime around ObjC, this name mangling approach seems like a very minimal solution that would be pretty fragile.


In my (possibly deluded) dreams I see ObjC namespaces being first class citizens, just like Class and Protocol. I have no idea how this would like in Modula-2, but in ObjC I would imagine:


@interface NSNamespace : NSObject
{
...
}
+ (NSNamespace *)globalNamespace;
+ (NSNamespace *)namespaceNamed:(NSString *)name; // takes 'foo::bar' format strings
- (NSNamespace *)parentNamespace;
- (NSArray *)childNamespaces
- (NSNamespace *)createChildNamespace:(NSString *)name;


- (void)addClass:(Class)cls; // just like objc_addClass, but scoped
- (void)addClass:(Class)cls withName:(NSString *)name; // new; creates an alias of the class
- (void)poseClass:(Class)cls; // just like class_poseAs, but scoped
- (Class)classNamed:(NSString *)className; // just like NSClassFromString(), .... you get the point


// open question of whether you can have other symbols in the namespace (global variables like NSString notification names would be particularly useful)

@end

Brilliant! If namespace ever happens to Objective C, I hope it would look like this.



Marco Scheurer Sen:te, Lausanne, Switzerland http://www.sente.ch

_______________________________________________
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

This email sent to email@hidden
References: 
 >Namespaces and ObjC (From: ObjM2 <email@hidden>)
 >Re: Namespaces and ObjC (From: glenn andreas <email@hidden>)
 >Re: Namespaces and ObjC (From: ObjM2 <email@hidden>)
 >Re: Namespaces and ObjC (From: "Timothy J. Wood" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.