Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 20, 2018 19:36:57 Steven Schveighoffer via Digitalmars-d wrote: > On 4/20/18 5:40 PM, Jonathan M Davis wrote: > > On Friday, April 20, 2018 16:35:43 Steven Schveighoffer via > > Digitalmars-d > > > > wrote: > >> On 4/17/18 4:49 PM, Steven Schveighoffer wrote: > >>> On 4/17/18

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 20, 2018 19:27:20 Steven Schveighoffer via Digitalmars-d wrote: > On 4/20/18 6:46 PM, Giles Bathgate wrote: > > On Friday, 20 April 2018 at 22:21:13 UTC, Jonathan M Davis wrote: > >> Honestly, I think that it's a terrible idea to special-case it like > >> that. If we want to

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Steven Schveighoffer via Digitalmars-d
On 4/20/18 7:21 PM, Giles Bathgate wrote: On Friday, 20 April 2018 at 23:13:58 UTC, Jonathan M Davis wrote: Yes. That should work. e.g. this import std.stdio; void foo(lazy string l) { } void main() {     foo({writeln("foo"); return "str";}()); } compiles and runs just fine without printing

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Steven Schveighoffer via Digitalmars-d
On 4/20/18 5:40 PM, Jonathan M Davis wrote: On Friday, April 20, 2018 16:35:43 Steven Schveighoffer via Digitalmars-d wrote: On 4/17/18 4:49 PM, Steven Schveighoffer wrote: On 4/17/18 12:18 PM, Nick Treleaven wrote: Thanks for making this pull, I've thought about solving this before. I think

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Steven Schveighoffer via Digitalmars-d
On 4/20/18 6:46 PM, Giles Bathgate wrote: On Friday, 20 April 2018 at 22:21:13 UTC, Jonathan M Davis wrote: Honestly, I think that it's a terrible idea to special-case it like that. If we want to argue for making it work in the language, that's fine, but if we special-case it like this, then

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Giles Bathgate via Digitalmars-d
On Friday, 20 April 2018 at 23:13:58 UTC, Jonathan M Davis wrote: Yes. That should work. e.g. this import std.stdio; void foo(lazy string l) { } void main() { foo({writeln("foo"); return "str";}()); } compiles and runs just fine without printing anything, whereas you get a compilation

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 20, 2018 22:46:54 Giles Bathgate via Digitalmars-d wrote: > On Friday, 20 April 2018 at 22:21:13 UTC, Jonathan M Davis wrote: > > Honestly, I think that it's a terrible idea to special-case it > > like that. If we want to argue for making it work in the > > language, that's fine,

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Giles Bathgate via Digitalmars-d
On Friday, 20 April 2018 at 22:21:13 UTC, Jonathan M Davis wrote: Honestly, I think that it's a terrible idea to special-case it like that. If we want to argue for making it work in the language, that's fine, but if we special-case it like this, then it will work with some functions that have

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 20, 2018 22:03:04 Giles Bathgate via Digitalmars-d wrote: > On Friday, 20 April 2018 at 20:35:43 UTC, Steven Schveighoffer > > wrote: > > Let me say I was surprised that this doesn't actually work. An > > in-line lambda will NOT work as a lazy parameter, even though > > that's

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Giles Bathgate via Digitalmars-d
On Friday, 20 April 2018 at 20:35:43 UTC, Steven Schveighoffer wrote: Let me say I was surprised that this doesn't actually work. An in-line lambda will NOT work as a lazy parameter, even though that's EXACTLY what a lazy parameter is implemented as! And variadic lazy parameters are

Re: Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Jonathan M Davis via Digitalmars-d
On Friday, April 20, 2018 16:35:43 Steven Schveighoffer via Digitalmars-d wrote: > On 4/17/18 4:49 PM, Steven Schveighoffer wrote: > > On 4/17/18 12:18 PM, Nick Treleaven wrote: > >> Thanks for making this pull, I've thought about solving this before. I > >> think the function needs to provide a

Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.

2018-04-20 Thread Steven Schveighoffer via Digitalmars-d
On 4/17/18 4:49 PM, Steven Schveighoffer wrote: On 4/17/18 12:18 PM, Nick Treleaven wrote: Thanks for making this pull, I've thought about solving this before. I think the function needs to provide a way to tell if the value was already present. Not as straightforward, but it can be done: