6 ms·
> 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?).
by taumhn 13y 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?).
- mistercow 13y agoAnnounced in 2006, released in 2007 with Mac OS X 10.5.
- mikeash 13y agoIt'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.
- gress 13y agoFor 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.
- mikeash 13y agoProperties are, but dot syntax is almost entirely not about properties.
- gress 13y agoI'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?
- mikeash 13y agoBecause... 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.)
- gress 13y agoIf 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.
- mikeash 13y agoWell no, the wishy-washy "properties are certain kinds of methods that we can't really define in a particularly concrete manner" definition of properties is the arbitrary one. Saying that properties are those things which are declared with @property is pretty non-arbitrary. That's the definition the compiler users, that's the definition the runtime uses, and that's the definition I use. Using the wishy-washy definition doesn't help, in any case. Nobody would say that e.g. autorelease is a "property", but you can still call it with dot syntax.
- gress 13y agoI seriously doubt your intellectual integrity here. You know that the dot syntax is a mechanism that matches with the conventions for property access, and no other access pattern. You also know that its possible to call zero argument methods that aren't accessors using the dot syntax. I don't believe that you think that this is the purpose for which the dot syntax was designed, and yet you bring up 'autorelease' to support your position. As I said, based on your specific definition, you are correct, but using denigration, a false straw-man 'quotation', and dishonest examples doesn't make your definition fit the evidence. As I said, and you sidestepped, properties pre-date the directive, therefore the directive cannot be the sole definition of what properties are.
- kbd 13y agoYes 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.
- mikeash 13y agoSure. And I'm just saying that it doesn't really matter what year ObjC got them because they're not a big deal anyway.