discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Property syntax and readability (was Re: Strange crash in __objc_res


From: Jason Felice
Subject: Re: Property syntax and readability (was Re: Strange crash in __objc_resolve_class_links)
Date: Wed, 16 Feb 2011 10:52:55 -0500

As the author of the originally offending code, I must reply.

I really didn't have grand philosophical reasons for using property syntax.  In fact, if philosophy were my primary concern, I would avoid it because the property syntax, as implemented, is a pretty leaky abstraction.  David's post-increment example aside, I find it troubling that you need to have declared something as a property in order to use foo.property as an rvalue instead of [foo property] and foo.property as an lvalue instead of [foo setProperty:].  This makes it an alternate syntax which does not completely work.  If instead it were simply alternate syntax for invoking x or setX and did not need to be declared, this would allow for more expressive code without complicating the underlying abstraction.

Actually, just declaring properties seems bunk.  This is an implementation detail which should be encapsulated, no?

You pretty much know when you've got a struct or an object, so I don't buy that.  You can't be reasoning about what foo.x does before you've figure out what foo is.  And this isn't Haskell, if someone makes a property with side effects, that's their problem, not a language design issue.

Anyway, the reasons I use it are much less pure.  I've been hacking Objective-C code for five months now, and I find it wholly unreadable.  I like the Smalltalk message naming, this is expressive and useful; however, I find Objective-C's use of square braces very difficult to parse visually.  Using property syntax makes expressions easier for me to read. I've been meaning to ask whether this goes away - perhaps I'm just getting too old to learn new tricks.

The other thing is that declarations of interfaces, protocols, and implementations in Objective-C very much look like statements rather than beginnings-of-constructs and ends-of-constructs.  In C and C++, I can scan a header file and go, "there's two classes in there, and they interact thusly".  In Objective-C it just seems like an amorphous blob of @foo directives and method declarations and I often miss that there's more than one object in a header.  Is this just my brain?  Xcode's and Vim's syntax highlighting?

I mean, I've been thinking of writing _comments_ (*gasp*) in order to have something break up the monotony so that you can pick out distinct objects visually.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]