D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18876 - Contradiction in Spec Concerning Properties
Summary: Contradiction in Spec Concerning Properties
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-19 16:04 UTC by Bolpat
Modified: 2024-12-15 15:25 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bolpat 2018-05-19 16:04:40 UTC
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
Comment 1 Jonathan M Davis 2018-06-01 08:14:02 UTC
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.
Comment 2 dlangBugzillaToGithub 2024-12-15 15:25:03 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dlang.org/issues/4088

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB