Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-08 Thread Steven Schveighoffer via Digitalmars-d
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

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-08 Thread Steven Schveighoffer via Digitalmars-d
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 () {}

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-08 Thread Nick Sabalausky via Digitalmars-d
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

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-07 Thread Nemanja Boric via Digitalmars-d
On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote: That's really confusing. I've used D for quite a while, and didn't know that. Admittedly I doubt I've ever tried () => { }, but given languages like C# which this syntax was partially taken from(?), that behaviour is very unexpected.

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-07 Thread Jesse Phillips via Digitalmars-d
On Sunday, 6 November 2016 at 00:19:57 UTC, Chris Wright wrote: On Sat, 05 Nov 2016 20:15:14 +, Kapps wrote: Admittedly I doubt I've ever tried () => { }, but given languages like C# which this syntax was partially taken from(?) D had delegates of that form years before C# had short-form

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread ixid via Digitalmars-d
On Saturday, 5 November 2016 at 20:22:13 UTC, 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

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread Chris Wright via Digitalmars-d
On Sat, 05 Nov 2016 20:15:14 +, Kapps wrote: > Admittedly I doubt I've ever tried () => { }, but given languages > like C# which this syntax was partially taken from(?) D had delegates of that form years before C# had short-form delegates. Otherwise it would likely have followed suit.

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread Adam D. Ruppe via Digitalmars-d
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

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread Kapps via Digitalmars-d
On Saturday, 5 November 2016 at 10:09:55 UTC, Adam D. Ruppe wrote: On Saturday, 5 November 2016 at 08:27:49 UTC, Nemanja Boric wrote: // This - does nothing variant.visit!((string s) => { enforce(false); x = 2; }, It calls the function... which returns a delegate, which you

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread Nemanja Boric via Digitalmars-d
On Saturday, 5 November 2016 at 10:09:55 UTC, Adam D. Ruppe wrote: On Saturday, 5 November 2016 at 08:27:49 UTC, Nemanja Boric wrote: [...] It calls the function... which returns a delegate, which you never called. This is one of the most common mistakes people are making: {} in D is a

Re: Why doesn't std.variant.visit automatically call the provided delegates?

2016-11-05 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 5 November 2016 at 08:27:49 UTC, Nemanja Boric wrote: // This - does nothing variant.visit!((string s) => { enforce(false); x = 2; }, It calls the function... which returns a delegate, which you never called. This is one of the most common mistakes people are