Professional Documents
Culture Documents
Why Doesn't Objective-C Have Namespaces? - Stack Overflow
Why Doesn't Objective-C Have Namespaces? - Stack Overflow
askedNov29'10at10:33 zoul 38.5k 8 86 154 Forwhatit'sworth,Iwouldn'tpreferNeXTSTEP::ArrayoverNSArray.Sillyasyoumightfindtheprefixthing,I thinkthefactthatthenamesdon'tcontainanysymbolcharactersfitsnicelyintothesentencelikestructureof theObjectiveCsyntax.w.mNov29'10at11:24 @w.m:Butyou'sdreaditas"Nextsteparray"not"Nextstepcoloncolonarray"inmuchthesamewayasyou read o b j e c t A t I n d e x : ias"objectatindexi"not"objectatindexcoloni".Thepointismootasfarasthe NSclassesareconcernedanyway.Youcan'tmovethemtoanewnamespacewithoutbreakingallexisting Cocoasoftware.JeremyPNov29'10at11:40 Also,youwouldn'treferenceitas N e x t s t e p : : A r r a yeachtime,you'dhaveone u s i n g N e x t s t e p ;andthen justreferenceitas A r r a y,unless therewasanambiguityandthenyou'dfullyresolveit.Itwouldactually makethecodecleanerandmorereadable.chaiguyMar1at22:22
2 Answers
Idon'tknowtheanswerbutIsuspect"it'sharderthanitlooks"isprobablyit.Youwouldhaveto introducesupportinthecompilerandlinkerinawaythatdoesn'tbreakexistingsoftware.Andwhilethis isobviouslypossible(C++hasalreadydoneit)presumablythetoolchainteamhavehadhigher prioritiesontheirplate.e.g.intherecentpastwehavehadgarbagecollection,GCD,blocksand ObjectiveC2.0appearsowecan'tsaytheyhavebeendoingnothing. NamespacesupportistheonethingthatIwoulddearlylovetoseeintroducedtoObjectiveC.
answeredNov29'10at11:33 JeremyP 33.7k 3 29 51
stackoverow.com/questions/4302872/whydoesntobjectivechavenamespaces
1/2
3/16/13
You'vetowrapeverythingi'vesaidinabigIMHOD
answeredNov29'10at11:31 LucaBernardi 1,569 1 9 22
3 Itwouldbeenough,Ithink,toprovidenamespacesupportforclassnames.Thesewouldbemangledin
somewaysothat,atruntime,therewouldbelittleornooverhead.JeremyPNov29'10at11:36
Not the answer you're looking for? Browse other questions tagged objectivec
namespaces or ask your own question.
stackoverow.com/questions/4302872/whydoesntobjectivechavenamespaces
2/2