Why don't lazy parameters bind to delegates? Was: Feature to get or add value to an associative array.
Steven Schveighoffer
schveiguy at yahoo.com
Fri Apr 20 23:38:25 UTC 2018
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 anything, whereas you get
>> a compilation error if you don't have the parens after the closing brace.
>
> Ok cool. I've updated the PR since basically, I agree with your points
> about it being confusing to cater for the special case.
>
>
Yeah, I didn't mean for the special case to happen -- I thought it just
worked!
I should have tested my original code... Sorry.
-Steve
More information about the Digitalmars-d
mailing list