Skip to content
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

Contradiction in Spec Concerning Properties #4088

Open
dlangBugzillaToGithub opened this issue May 19, 2018 · 1 comment
Open

Contradiction in Spec Concerning Properties #4088

dlangBugzillaToGithub opened this issue May 19, 2018 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Bolpat reported this on 2018-05-19T16:04:40Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=18876

CC List

Description

In section "Property Functions"[1] of "Functions" page, it says on 
2., second point: "@property functions can only have zero, one or two parameters."
and on
8.: "If a property function has no parameters, it works as a getter. If has exactly one parameter, it works as a setter."

These cannot be understood simultaneously. 8. implies a @property must have one or no parameters.

[1] https://dlang.org/spec/function.html#property-functions
@dlangBugzillaToGithub
Copy link
Author

issues.dlang (@jmdavis) commented on 2018-06-01T08:14:02Z

The cases of a free function used without UFCS, a free function used with UFCS, and a member function are all different, and the number of parameters required differs. So, the spec needs to be clarified in that respect. Point #8 is correct for a free function used without UFCS or a member function, but it's wrong for a free function used with UFCS. A free function used with UFCS needs on extra parameter for both the getter and setter - hence why it's possible to have a setter property with two parameters.

But regardless, that whole section of the spec needs to be rewritten anyway, since while it was intended at one point that property functions be controlled by @property, that never actually happened. So, all of these rules relate to using any function as a property and aren't actually affected by @property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant