DIP23 draft: Fixing properties redux

Johannes Pfau nospam at example.com
Sun Feb 3 02:14:32 PST 2013


Am Sun, 03 Feb 2013 03:16:08 -0500
schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:


> It is understood that the current proposal is just a draft and there 
> must be quite a few corner cases it doesn't discuss. We also
> understand it's impossible to reconcile all viewpoints and please all
> tastes. Our hope is to get to a point where the rules are
> self-consistent, meaningful, and complete.
> 
> 
> Destroy.
> 
> Andrei

"If a function returns a reference, then assignment through the
paren-less call should work: "

This is the only part where I would disagree. Why is this special rule
necessary if we have full @property support? I think this would still
allow too many false positives.

One important aspect that this proposal doesn't cover yet is whether we
want to allow "semantic rewriting" for properties:
----
Struct a;
a.property++; //would this be legal?
----

for other corner cases this list is a good start:
http://wiki.dlang.org/Property_Discussion_Wrap-up#Implementation_concerns

* Can we get a reference to the property? What does
  &x.property mean?
* How can we get the getter / setter functions? Do we need to get those?
* What is the type of the property? Return type, setter function type
  or getter function type? How to get the other types?
* What does x.property++ do?
  ([http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Property#Semanticrewritingofproperties
  Semantic rewriting])
* Is returning ref values from the getter OK?
* Is taking ref values in the setter OK?
* Should all properties be nothrow? pure? getter const?
** Probably better as a rule for style guide.
* Are UFCS properties possible? How do they work exactly?
* How do you disambiguate property functions when they're free
  functions which conflict?
** Normal UFCS functions can be force
  called by using their fully qualified name. That's not possible for
  properties if function call syntax is disallowed?
* How many parameters are allowed for property functions?
** Are default parameters allowed?
** Especially consider the example about __FILE__ and __LINE__
* Are templated properties allowed?
** The access syntax for properties doesn't allow providing types



More information about the Digitalmars-d mailing list