Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 09 Mar 2013 03:30:49 -0600 From: "Chris Uppal" Newsgroups: comp.programming References: <5d7a408b-e89e-41dc-b70f-b9951e449cba@googlegroups.com> Subject: Re: taxing syntax Date: Sat, 9 Mar 2013 09:27:29 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 Message-ID: Lines: 59 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-u0jFRUgcUhJ1Oiw3aaB3AAQpjRHZQoiScts9Pa0Gem6lVEkul2am0LLnutqFx4B+GZQ+ZClqj179Yg2!F1a4nW4G6KUY+5z7FLKeJxsVz0kV/FpnS7T/KwysgzM/NOjlPKlsHvcOtmYuZDjvUFbShvkh//0= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3022 Xref: csiph.com comp.programming:3148 bob wrote: > - (return_type)instanceMethod2WithParameter:(param1_type)param1_varName > param2_callName:(param2_type)param2_varName; > > Am I the only one who finds this extremely unnatural? In particular, the > type appearing in parentheses is strange to me. You'll get used to it ;-) Anyway, I don't know Objective C, but the syntax appears to be an effort to combine the syntax of Smalltalk methods (which works very well) with a statically typed language. Smalltalk is dynamically typed, so the above example would be expressed as: instanceMethod2WithParameter: param1_varName param2_callName: param2_varName ... function body... or, with some noise removed: instanceMethod: var1 param2: var2 ... function body... The OO parts of Objective C are, I believe (though I can't cite a reference), directly taken from Smalltalk, so that seems the likely history. It may be that the use of brackets around the type name is influenced by the C "cast" syntax, and is intended to suggest that you are "casting" the underlying object reference (i.e. a Smalltalk-style untyped reference) to the declared type, but that's mere speculation. The syntax certainly looks clumsy to me. Perhaps they'd have been better off with something parallel to the original C syntax where the parameters were named in the function header, but type declarations were made separately. return_type instance_method(var1, var2) type1 var1; type2 var2; { ... function body... } (That's from 20+ year old memory, so I may have the details wrong). So -- in the hypothetical case -- the Objective-C method would have read: return_type instanceMethod: var1 param2: var2 type1 var1; type2 var2; { ... function body... } -- chris