shouting versus dotting
Benji Smith
dlanguage at benjismith.net
Wed Oct 8 14:07:41 PDT 2008
Simen Kjaeraas wrote:
> On Tue, 07 Oct 2008 16:27:00 +0200, Benji Smith
> <dlanguage at benjismith.net> wrote:
>
>> Jarrett Billingsley wrote:
>>> On Mon, Oct 6, 2008 at 6:59 AM, Denis Koroskin <2korden at gmail.com>
>>> wrote:
>>>
>>>> If we don't omit parenthesises, the ambiguity goes away:
>>>>
>>>> foo()(5)
>>>> foo(5)()
>>>>
>>> No it doesn't.
>>> Stdout("foo")("bar!").newline;
>>
>> This is one of the main reasons I dislike opCall.
>>
>> Combined with optional-parentheses for function invocation, opCall is
>> a poison-pill that creates a lot of potential ambiguities and prevents
>> the implementation of more compelling features.
>>
>> --benji
>
> void delegate() foo()
> {
> return delegate void() {);};
> }
>
> ?
>
Is that supposed to be legal code?
I'll assume this is what you meant to write:
void delegate() foo()
{
return delegate void() { };
}
...and that you're making the point that opCall introduces no more
ambiguities than delegate-call syntax. And I suppose you're right.
But people use opCall *everywhere* for all sorts of crazy crap, and I
think it makes the code far less readable. When the call syntax is used
for actual delegates, I don't really mind. But I think call-chaining
with opCall is a huge eye-sore:
object(x)("hello")();
I guess my ambiguity argument is invalidated by wanting to keep the
delegate-call syntax. I just hate when it's applied to non-delegates.
--benji
More information about the Digitalmars-d
mailing list