discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Strange crash in __objc_resolve_class_links


From: Ivan Vučica
Subject: Re: Strange crash in __objc_resolve_class_links
Date: Wed, 16 Feb 2011 19:56:25 +0100


On 16. vel. 2011., at 15:52, David Chisnall wrote:

Yes, if the dot notation had been properly considered then it would have enforced these additional requirements:

- Accessor methods supplied for properties must not have side effects
- Accessor methods supplied for properties must always return the value provided for the last set operation.

That would kill the whole point of having them as methods, don't you think? :)

- Only methods declared with @property may be called with the dot notation

I think this is enforced on iOS. Not sure, though. From what I caught, that was the general intention on Cocoa, but they didn't want to patch every single old header and require patching of old libraries.


If they had made these requirements, then the dot notation would have added something of value to the language.  At present, it is semantically equivalent to a message send and may be used interchangeably with a message send.  Since it is semantically equivalent, it does not provide any more information to the reader or to the compiler, it just does something that looks like a field access (which is one of the fastest operations in C) and actually makes it into a message send or two (which are an order of magnitude slower), making it hard to reason about the behaviour of the code.  

Agreed, they should have provided at least the options to note that you will explicitly not customize the method.


I really think that this is a minor issue and that extra brackets in such short statements do not contribute to readability of code. Most often, one will not write code that will depend on atomicity of the operation. I don't write multithreading code because I don't want to worry about atomicity, locking, race conditions, et cetera.

Then I hope you never have to write any code that is CPU dependent, since current trends are towards lots of slower cores.

I hope the same; despite being primarily into games, I haven't ran into problems where I had to optimize on that level. After all, most complexity is in drawing and optimizing drawing, and sadly, OpenGL contexts cannot be accessed from different threads on most platforms.


But whenever I use dot-syntax, I am very conscious of what I'm doing; I am conscious that I am making a method call (or two!) and it's not an issue. And, after all, large majority of my properties are synthesized. What harm in using that?

You are thinking about yourself, not about the people reading your code.  This is the fastest path to unmaintainable code that I have encountered.  I can point to places in GNUstep and other projects where people have had the same philosophy.  These people have subsequently moved on to other projects, and no one wants to touch the code.  

Good point. I will reconsider my position.




Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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