Thread overview | |||||
---|---|---|---|---|---|
|
November 13, 2011 [Issue 6942] New: lazy parameters can break purity | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6942 Summary: lazy parameters can break purity Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: timon.gehr@gmx.ch --- Comment #0 from timon.gehr@gmx.ch 2011-11-13 04:48:46 PST --- int foo(lazy int x) pure{ return x()+x(); } void main(){ auto a=foo((writeln("impure"),1)); } This compiles and prints impure impure -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 13, 2011 [Issue 6942] lazy parameters can break purity | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6942 --- Comment #1 from timon.gehr@gmx.ch 2011-11-13 04:54:18 PST --- note that int foo(int delegate() x) pure{ return x()+x(); } void main(){ auto a=foo({return writeln("impure"),1;}); } fails with Error: pure function 'foo' cannot call impure delegate 'x' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 03, 2011 [Issue 6942] lazy parameters can break purity | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=6942 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-02 18:56:15 PST --- The pureness of lazy parameter belongs to the *caller side*, not callee side. It is a design. One use case is std.exception.enforce. It receives a condition as a lazy parameter, but whole enforce function can become pure with the design. Delegate parameter is similar to lazy parameter, but it is different in this point. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation