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

clarify what @property actually does #1141

Merged
merged 1 commit into from
Oct 28, 2015
Merged

Conversation

WalterBright
Copy link
Member

I gleaned these from reading the dmd source code. How they worked had changed around so much over the years, I did not know just how @Property interacted with UFCS. This clarifies it, or at least enumerates the effects.

@aG0aep6G
Copy link
Contributor

@property is also documented at http://dlang.org/function.html#property-functions which is linked from http://dlang.org/attribute.html#property. We should probably merge things into one.

$(UL
$(LI $(CODE @property) functions cannot be overloaded with non $(CODE @property) functions with the same name.)
$(LI $(CODE @property) functions can only have zero, one or two parameters.)
$(LI $(CODE @property) functions cannot have variadic parameters.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three points above are also mentioned later on, between the code samples. And it says "Properties may only have zero or one parameter" (not two) there.

@WalterBright
Copy link
Member Author

You're right, I need to some more work here.

@andralex
Copy link
Member

thx for doing this! lmk when ready

@WalterBright
Copy link
Member Author

I merged the two descriptions in property.html and function.html into one in function.html. Had to revamp the 'Optional Parentheses' section as well. Removed bogus examples.

@@ -123,7 +123,7 @@ $(H4 $(LNAME2 pure-functions, Pure Functions))

$(P Pure functions are functions which cannot access global or static, mutable
state save through their arguments. This can enable optimizations based on the fact
that a pure function is guaranteed to mutate nothing which isn't passed to it,
that a pure function is guaranteed to mutate nothing which is not passed to it,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (previous) phrasing is quite awkward. Let's take this opportunity to change the text to:

This enables optimizations based on the fact that a pure function may at most mutate state reachable through its parameters.

@andralex
Copy link
Member

lgtm after these nits

andralex added a commit that referenced this pull request Oct 28, 2015
@andralex andralex merged commit 06a977a into dlang:master Oct 28, 2015
@WalterBright WalterBright deleted the property branch October 28, 2015 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants