|
From: | Luke Kendall |
Subject: | Re: OC method call in style of CPP rather than message sending |
Date: | Mon, 6 Nov 2023 18:53:21 +1100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.24) Gecko/20101027 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
I agree with Daniel.
Objective C was developed following Smalltalk, at a time when its method syntax was very influential in language design and the whole Object Oriented model of programming was a very new thing.
I came to very much prefer the very distinctive syntax, since it made it very clear when you were using objects (and thus there could be extra layers of work being done by the compiler or runtime to handle the construct), and when you were using simple functional programming.
Provided your code editor supported bracket checking, it was very easy to see and understand the nesting level. From memory IIRC our coding standard adopted the convention of breaking out the square brackets to vertically match if the line got very long.
Personally I think having Smalltalk syntax and C syntax to demarcate the two kinds of code is clear, if a little unusual in a language design.
Adding in a 3rd syntax from another language, especially one that straddles the two programming models (OO *and* functional) might allow some subtle mistakes to be made.
Just my two cents.
luke
I’m far from the being an authority on ObjC relative to others on this listserv, but I’ll 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) — in other words, it was developed at a time before the C++-style syntax had become a de facto standard. ObjC’s syntax style was largely derived from Smalltalk.
Personally, I like ObjC’s syntax. It was certainly a change from what I was used to, but I actually prefer it in a lot of scenarios. The time when I don’t 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—that’s kind of a meaningless question. That syntax, for all intents and purposes *is* Objective C. I think what you’re trying to ask is whether you can do Cocoa programming using C++. Someone probably has worked on that at some point, but I suspect it’s not well supported. My suggestion is to try and learn Objective C and you may be surprised to learn that you like it after you get used to it :)
Cheers,Daniel
Sent from my iPhone
On Nov 5, 2023, at 09:13, loserism <loserism@88.com> wrote:
Hi all.
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: <args>]?
instead of
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 instead of the more generic method calling style, I don't believe it's a technicality!
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 knowledgeable group of OC experts, and I hope to get a reply from you. Thank you all!
Best Regards!
_______________________________________________ apps-gnustep mailing list apps-gnustep@gnu.org https://lists.gnu.org/mailman/listinfo/apps-gnustep
[Prev in Thread] | Current Thread | [Next in Thread] |