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
On 6/11/23 02:43, Daniel Boyd via apps-gnustep wrote:
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 <[email protected]> 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>]?
obj.methodA(<args>).methodB(<args>)... .methodN(<args>)
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 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
[email protected]
https://lists.gnu.org/mailman/listinfo/apps-gnustep
_______________________________________________
apps-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/apps-gnustep