[Issue 9426] New: [enh] polymorphic lambda should be storeable in enum constant
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 29 16:02:08 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9426
Summary: [enh] polymorphic lambda should be storeable in enum
constant
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: code at dawg.eu
--- Comment #0 from Martin Nowak <code at dawg.eu> 2013-01-29 16:02:07 PST ---
I don't see a compelling reason why we should disallow assigning polymorphic
lambdas to manifest constants.
This would allow the following code to work.
enum foo = bar => bar * 2;
foo(10);
foo!uint(10); // probably too
The equivalent template would be.
template foo(T) { auto foo(T bar) { return bar * 2; } }
This is for example very handy to replace C-style macros.
#define MASK(val) ((val) & 0xF)
vs.
enum MASK = val => val & 0xF;
related: Bug 7176, Bug 8452
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list