Hacker News new | ask | show | jobs
by b3morales 1654 days ago
This is in fact how @property works; the declaration is sugar for a pair of accessor methods. The dot syntax is sugar for calling those methods.

    #include <Foundation/Foundation.h>

    @interface Foo : NSObject
    @property (copy) NSString *bar;
    @end

    @implementation Foo
    @end

    int main(int argc, char *argv[]) {
        Foo *foo = [Foo new];
        [foo setBar:@"Hello, world!"];
        NSLog(@"%@", [foo bar]);
        return 0;
    }
1 comments

The dot syntax makes it difficult to parse whether you are dealing with a C struct or an Objective-C object.

Objective-C was grafted onto C with very clear demarcation lines.

We don’t mind being able to declare a property with `@property`. We do mind that they introduced dot syntax

Same here, I was never a proponent of the dot syntax. As we know, compiler development at Apple got taken over at some point by C++ people, and we can all see the results: https://blog.metaobject.com/2014/06/remove-features-for-grea...
t.rotate (a, v); // Original

t rotate (a, v); // Who needs dot?

t rotate a, v; // Who needs brackets?

t rotate by: a around: v; // Who needs ambiguity?

t rotateBy: a around: v // This is Smalltalk

I’m rolling — this is perfect.

Civilization has used dot notation in basically all thought, as evidenced by pretty much any nation’s laws / code

Which of course means it's in no way ambiguous or overly used. One syntax for one purpose. Until dot notation was used for @property you never had to guess if you were looking at a structure or at a class. See how that works?
Greg—the funny thing is that the comment I read the comment where they explain notation differences as sort of saying that Smalltalk is the best thing on the planet and we should all aspire to be Smalltalk. No ambiguity with Smalltalk which is of course the whole point of readable, paintable code. The most easily maintainable code is that which does not need documentation.

On Smalltalk: Objective-C of course aspires to be Smalltalk. It just so happens that it's happy to be a muggle and integrate C as well. Good for us. Use Smalltalk for most things and C where necessary.