-
-
Notifications
You must be signed in to change notification settings - Fork 740
Strict @property syntax compliance (-property) #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think that user-defined init is a property. |
@shoo: Are you referring to |
@klickverbot: Yes, I commented to druntime's one (Sorry). |
@shoo: The problem is that making |
I did not know that it had been already discussed... My opinion: On the other hand however, this problem must be corrected with a big breaking change sometime. |
@shoo: »It is a clear design fault that TypeInfo.init does not return TypeInfo.« I don't know if this is clear to you anyway and I'm just misunderstanding you, but no, the design fault is not that TypeInfo.init returns Besides, I don't think I agree with your point that |
@klickverbot: |
@shoo: I don't think »the priority does not exist« – the spec lists |
I do not deny your opinion. I can catch a meaning like that. However, it is possible as follows to catch a meaning. |
{ | ||
return _family; | ||
} | ||
|
||
/// Property that indicates if this is a valid, alive socket. | ||
bool isAlive() const // getter | ||
@property bool isAlive() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that isFoo is not property.
If the name begins with a verb, it is not a property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a strict »if the name contains a verb, it's not a property« rule works well here – the »is« prefix in »isFoo« does not represent any change to the object state (like »make«, »do«, etc. would), but is a commonly used naming convention for boolean fields (»Is it alive?«).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be the problem of likes and dislikes, too.
Because I have a confused idea, I itemize it:
- For example, Range.empty does not have "is". This naming lacks in consistency...?
- I feel the old custom that names getter-property getFoo in this.
- Is not isFoo an action to refer to an object for a state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAlive
was clearly intended to be a property (the doc comment even explicitly mentions it), but @property
annotations simply didn't exist in the pre-1.0 days when the code was written.
Using an »is« prefix for boolean fields is a fairly wide-spread naming convention, obviously with its own pros and cons – see e.g. Code Complete. It is used in quite a few places all over Phobos, also in conjunction with @property
, not only free »predicate methods« (e.g. isEnd
, isLeapYear
, isDir
, isSymlink
, …), and, yes, the names in Phobos are not consistent in that regard. Of course, these choices could be discussed, but I think here in this pull request is neither the right place nor time to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This disagreement is a reflection of what I feared when opposing @Property: everybody will have a slightly different opinion about exactly what's a property and what's not. To add to the quarrel, here's mine: If it doesn't change the object and always returns the same thing for equal objects, it's a property. Otherwise, it's not.
This enables the test suite to build with the -property switch enabled. std.cpuid: vendor()/processor() have not been converted to properties in accordance to core.cpuid. std.xml: Element.text() cannot be a property due to the optional parameter.
I reviewed it as possible in detail. I judge that there is not the fatal problem. After having put some periods of grace, I'll merge it. |
どうもありがとうございました (Did I get that right? I am still struggling with the very basics of Japanese) – reviewing this mess of tiny changes must've been very tedious. |
Thanks for this work, both of you. David, I should note that although this is clearly valuable, your time would be much more gainfully spent on the Thrift bindings. Thanks! |
Strict @Property syntax compliance (-property)
@andralex: Actually, the Thrift bindings were the very reason for these changes (which I had in the pipe for quite some time now) – I wanted to make sure that they don't fall apart when someone tries to use |
posix.mak: use -f to fix nightlies merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
Makes library and unit tests build with
-property
and adds the switch to the default build to avoid regressions. Requires dlang/druntime#97, which has been merged in the meantime.The pull request also contains a few other commits with minor cleanup changes I made while going through the source.
Tested on OS X x86, Linux x86_64 and Windows x86.