While we're lynching features, how bout' them omittable parens?

Robert Fraser fraserofthenight at gmail.com
Tue May 19 13:04:23 PDT 2009


Chad J wrote:
> Nevermind properties.  Any chance we can forbid the omittable
> parentheses, at least in the lhs of an assignment expression?
> 
> In the more general case, any value type that gets modified but never
> read or copied elsewhere is probably either dead code, a bug, or a
> benchmark.  The latter is easy to fix by adding the necessary read/copy
> (return the value, pass it to a global or function, etc).  It'd be great
> if this kind of thing were a compile time error.
> 
> Code like this shouldn't compile:
> 
> struct S { int a = 0; }
> S foo() { S s; return s; }
> 
> void main()
> {
>     foo.a++;
> }

Whatever solution to this is chosen *please* don't make "get", "set", 
"value" or "prop" into keywords! "in", "out", "body" and "shared" used 
to be common features of my coding style; I'm not sure it can take 
another blow. As Andrei mentioned somewhere, keywords aren't cheap.



More information about the Digitalmars-d mailing list