November 08, 2016 Re: Why doesn't std.variant.visit automatically call the provided delegates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | On 11/8/16 11:31 AM, Nick Sabalausky wrote:
> On 11/05/2016 04:22 PM, Adam D. Ruppe wrote:
>> On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote:
>>> That feels like it should be a compiler warning.
>>
>> I'm now of the opinion that the {} delegates should be deprecated
>> (instead use () {} delegates)... this comes up a lot and there's a few
>> other places too where it is a pain... and it isn't that worth keeping
>> imo.
>
> I didn't even know you could create a delegate with just {} and no
> parens. Kinda confusing since, normally, {} by itself creates a scope,
> not a delegate.
Indeed:
{int x = foo; return x;} // scope
auto dg = {int x = foo; return x;} // delegate
The requirements seem to be that you have to use the {} syntax as an expression instead of a block.
omitting the initial parentheses seems like a really low benefit to having such confusing ambiguity. And of course, it leads to the horrible examples shown by OP.
-Steve
|
November 08, 2016 Re: Why doesn't std.variant.visit automatically call the provided delegates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 11/5/16 4:22 PM, Adam D. Ruppe wrote: > On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote: >> That feels like it should be a compiler warning. > > I'm now of the opinion that the {} delegates should be deprecated > (instead use () {} delegates)... this comes up a lot and there's a few > other places too where it is a pain... and it isn't that worth keeping imo. I created an enhancement request, as I didn't see any in the issue tracker already. https://issues.dlang.org/show_bug.cgi?id=16672 -Steve |
Copyright © 1999-2021 by the D Language Foundation