Hacker News new | ask | show | jobs
by taumhn 4589 days ago
> Objective-C is from 1983, do you? It's not exactly new

The dot-syntax for accessing object properties is much more recent though (2009?).

2 comments

Announced in 2006, released in 2007 with Mac OS X 10.5.
It's a pretty unimportant feature though. It's just some very minor syntactic sugar for a regular message send. All uses of obj.property can be replaced with either [obj property] or [obj setProperty:...] depending on whether it's being written or read. It's about as significant as when C added the ability to declare variables in the middle of a block or support for // style comments i.e. not at all.
Yes but that's pcwalton's point. The OP complained that Rust is slow, in part, because of that feature and pcwalton pointed out that A. most languages do it now and B. that it has no runtime cost because it's just sugar syntax.
Sure. And I'm just saying that it doesn't really matter what year ObjC got them because they're not a big deal anyway.
For now perhaps, but it does seem as though properties are gradually being lifted into a first class language feature rather than a set of conventions.
Properties are, but dot syntax is almost entirely not about properties.
I'm not sure I understand what you mean by that. Dot syntax is a way to refer to properties independent of the usual message sending syntax. How can it not be about properties?
Because... it's not?

Declare a plain getter method:

    -(id)foo;
Call it with dot syntax:

    id foo = obj.foo;
Works fine. Now declare it as a property:

    @property id foo;
Call it without dot syntax:

    id foo = [obj foo];
Works fine. They are completely unrelated and just introduced at the same time. You could take dot syntax out of the language without affecting properties in the least. You could take properties out of the language without affecting dot syntax in the least.

(There is one exception to this, and that is the part where dot syntax understands and calls custom getter/setter names for properties. But that is the only place where they even touch, and it certainly doesn't mean they're somehow integrated.)

If you define 'properties' as only use of the @property directive, then what you say follows.

However that's a pretty arbitrary definition, since properties pre-date the introduction of that directive.