Property discussion wrap-up
Zach the Mystic
reachBUTMINUSTHISzach at gOOGLYmail.com
Sun Jan 27 18:25:06 PST 2013
On Monday, 28 January 2013 at 00:07:05 UTC, Andrei Alexandrescu
wrote:
> I was thinking of just using &foo, like in C.
>
> BTW also regarding optional parentheses, while I was working on
> https://github.com/D-Programming-Language/tools/pull/41/files I
> refactored a bit of code to use UFCS and paren-less syntax. I
> must say I find this a very fluid style of programming that I'd
> hate to lose.
>
> One more thought - though optional parens and properties are
> distinct issues, there is some interaction: optional parens
> reduce the need for @property annotation on read-only
> properties.
>
>
> Andrei
It was pointed out by Maxim Fomin that my example was wrong. The
only question I had about &foo was if you're in a context where
you're not even sure if foo is callable or just plain data, &foo
could be silently accepted whereas cast(function) could say
"Error: foo is not castable as a function", which makes it safe
despite its appearance. The massive downside is simply that it's
not at all concise.
I first saw UFCS and optional parentheses in Ruby and it seemed
both alluring and deceptively simple. I will give you a thought
in return for your thought. Reading the other people's posts who
prefer always parens makes it seem that if they had to choose
between a Volvo and a Ferrari, they would choose the Volvo,
whereas you would choose the Ferrari. But the thing is, if the
Ferrari really is a damn good car, it's the best of both worlds.
Do you think the Ferrari (i.e. optional parens) has got what it
needs under the hood?
Also, the single-instance struct suggestion is another possible
way to eliminate @property entirely. They would all just be
single instance structs with no data of their own. opGet would
satisfy the sticklers by making parens downright illegal on
functions which call it.
More information about the Digitalmars-d
mailing list