Re: OC method call in style of CPP rather than message sending
Daniel Boyd <[email protected]> Sun, 5 Nov 2023 09:43:27 -0600
| Newsgroups | gmane.comp.lib.gnustep.bugs,gmane.comp.lib.gnustep.general,gmane.comp.lib.gnustep.applications,gmane.comp.lib.gnustep.user,gmane.comp.lib.gnustep.devel,gmane.comp.lib.gnustep.packagers,gmane.comp.lib.gnustep.marketing,gmane.comp.lib.gnustep.ui |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail-561E764F-FCC2-4E92-8185-A0FD06482440 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I=E2=80=99m far from the being an authority on ObjC relative to others on th= is listserv, but I=E2=80=99ll take a stab at responding. The reason ObjC has= its syntax is largely because it was developed around the same time as C++ (= slightly after, but close enough) =E2=80=94 in other words, it was developed= at a time before the C++-style syntax had become a de facto standard. ObjC=E2= =80=99s syntax style was largely derived from Smalltalk.=20 Personally, I like ObjC=E2=80=99s syntax. It was certainly a change from wha= t I was used to, but I actually prefer it in a lot of scenarios. The time wh= en I don=E2=80=99t like it is when you have a line that starts with [[[[ and= you have to really work to figure how many opening square brackets you need= . And regarding whether you can use C++-style syntax, to use ObjC=E2=80=94that= =E2=80=99s kind of a meaningless question. That syntax, for all intents and p= urposes *is* Objective C. I think what you=E2=80=99re trying to ask is wheth= er you can do Cocoa programming using C++. Someone probably has worked on th= at at some point, but I suspect it=E2=80=99s not well supported. My suggesti= on is to try and learn Objective C and you may be surprised to learn that yo= u like it after you get used to it :) Cheers, Daniel Sent from my iPhone > On Nov 5, 2023, at 09:13, loserism <[email protected]> wrote: >=20 > =EF=BB=BF > Hi all. > Is there a way for Objective-C to use C++ form of method calls? I.e. use o= bj.method(<args>) form of method call instead of [obj method: <args>]?=20 > obj.methodA(<args>).methodB(<args>)... .methodN(<args>)=20 > instead of > [.... [obj methodA: <args>] methodB: <args>] methodC: <args>]...] methodN:= <args>...] > I mean that use the method invocation style instead of the message sending= style. > I'm curious as to why OC must use the message sending style to stand out i= nstead of the more generic method calling style, I don't believe it's a tech= nicality! >=20 > By the way sorry, I came here to annoy you all because I couldn't find the= relevant answers on google and GPT, because I know you are the most knowled= geable group of OC experts, and I hope to get a reply from you. Thank you al= l! >=20 > Best Regards! --Apple-Mail-561E764F-FCC2-4E92-8185-A0FD06482440 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>I=E2=80=99m far from the being an auth= ority on ObjC relative to others on this listserv, but I=E2=80=99ll take a s= tab at responding. The reason ObjC has its syntax is largely because it was d= eveloped around the same time as C++ (slightly after, but close enough) =E2=80= =94 in other words, it was developed at a time before the C++-style syntax h= ad become a de facto standard. ObjC=E2=80=99s syntax style was largely deriv= ed from Smalltalk. </div><div><br></div><div>Personally, I like ObjC=E2= =80=99s syntax. It was certainly a change from what I was used to, but I act= ually prefer it in a lot of scenarios. The time when I don=E2=80=99t like it= is when you have a line that starts with [[[[ and you have to really work t= o figure how many opening square brackets you need.<br></div><div><br></div>= <div>And regarding whether you can use C++-style syntax, to use ObjC=E2=80=94= that=E2=80=99s kind of a meaningless question. That syntax, for all intents a= nd purposes *is* Objective C. I think what you=E2=80=99re trying to ask is w= hether you can do Cocoa programming using C++. Someone probably has worked o= n that at some point, but I suspect it=E2=80=99s not well supported. My sugg= estion is to try and learn Objective C and you may be surprised to learn tha= t you like it after you get used to it :)</div><div><br></div><div>Cheers,</= div><div>Daniel</div><div><br></div><div>Sent from my iPhone</div><div dir=3D= "ltr"><br><blockquote type=3D"cite">On Nov 5, 2023, at 09:13, loserism <l= [email protected]> wrote:<br><br></blockquote></div><blockquote type=3D"cite= "><div dir=3D"ltr">=EF=BB=BF<p style=3D"margin:0;">Hi all.</p><p style=3D"ma= rgin:0;">Is there a way for Objective-C to use C++ form of method calls? I.e= . use obj.method(<args>) form of method call instead of [obj method: &= lt;args>]? </p><table style=3D" border-collapse: collapse; table-layout: auto; font-size: inherit; border: 1px solid #D7D7D7; overflow: hidden;"><tbody><tr style=3D"border: 1px solid #D7D7D7;"><td colsp= an=3D"1" rowspan=3D"1" data-colwidth=3D"527" style=3D"border-right: 1px soli= d #D7D7D7; border-bottom: 1px solid #D7D7D7; padding: 3px 8px; height: 36px; word-break: break-all; overflow-wrap: break-word;"><p style=3D"margin:0;">obj.methodA(<arg= s>).methodB(<args>)... .methodN(<args>) </p></td></tr></= tbody></table><p style=3D"margin:0;"> </p><p style=3D"margin:0;">instead of<= /p><table style=3D" border-collapse: collapse; table-layout: auto; font-size: inherit; border: 1px solid #D7D7D7; overflow: hidden;"><tbody><tr style=3D"border: 1px solid #D7D7D7;"><td colsp= an=3D"1" rowspan=3D"1" data-colwidth=3D"770" style=3D"border-right: 1px soli= d #D7D7D7; border-bottom: 1px solid #D7D7D7; padding: 3px 8px; height: 36px; word-break: break-all; overflow-wrap: break-word;"><p style=3D"margin:0;">[.... [obj methodA:= <args>] methodB: <args>] methodC: <args>]...] methodN: &l= t;args>...]</p></td></tr></tbody></table><p style=3D"margin:0;">I mean th= at use the method invocation style instead of the message sending style= .</p><p style=3D"margin:0;">I'm curious as to why OC must use the message se= nding style to stand out instead of the more generic method calling style, I= don't believe it's a technicality!</p><p style=3D"margin:0;"><br></p><p sty= le=3D"margin:0;">By the way sorry, I came here to annoy you all because I co= uldn't find the relevant answers on google and GPT, because I know you are t= he most knowledgeable group of OC experts, and I hope to get a reply from yo= u. Thank you all!</p><p style=3D"margin:0;"><br></p><p style=3D"margin:0;">B= est Regards!</p></div></blockquote></body></html>= --Apple-Mail-561E764F-FCC2-4E92-8185-A0FD06482440--