@property needed or not needed?

Artur Skawina art.08.09 at gmail.com
Sun Dec 2 03:36:53 PST 2012


On 12/02/12 07:57, Jonathan M Davis wrote:
> On Sunday, December 02, 2012 07:49:52 deadalnix wrote:
>> And what do you think about map!(x => x * x) = generator(x, y, z)
>> ?
> 
> What's that even supposed to mean? map has been given no function argument 
> either as UFCS or with a normal function call, so it's not being called. And 
> even if it were, it wouldn't result in an lvalue, so putting it on the left of 
> an assignment makes no sense. I have no idea what you're trying to do here.

   void main() {
      import std.stdio;

      writeln!string = "Hello World!";
   }

   // The explicit "!string" is only needed because of no IFTI, if 'writeln' was
   // a function instead of a template you could just call it like "writeln = "blah".

Allowing that /by default/ does much more harm than good, proper property
enforcement is necessary. Function calls go via '()'. Programmer can override
when he knows better. UFCS doesn't change things. [1]

artur

[1] If you think the required '()' in UFCS chains look ugly, you're right, but the
right fix isn't to butcher the language. '()' carry important information. Having
a mode where function calls are made w/o the parens would be a good idea, but it
should be limited to an explicit scope. ie something like
"auto r = function {generator(x, y, z).map!(x => x * x)};", except 'function' keyword 
can't be overloaded like that, it's too long, and ()-less calls isn't the only change
that could be done.


More information about the Digitalmars-d mailing list