Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
June 19, 2009 [Issue 3081] New: unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3081 Summary: unaryFun can't be used to get element out of struct Product: D Version: 2.030 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: dsimcha@yahoo.com import std.algorithm; struct Foo { uint num; } void main() { Foo[] foos; auto bar = map!("a.num")(foos); } C:\dmd\windows\bin\..\..\src\phobos\std\functional.d(89): Error: static assert "Bad unary function: a.num for type Foo" This looks like overzealous error checking, as it worked in the old Phobos and now fails a static assert. Probably has to do with the fact that Foo is in a different module than std.functional.unaryFun. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 19, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 Jarrett Billingsley <jarrett.billingsley@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jarrett.billingsley@gmail.c | |om --- Comment #1 from Jarrett Billingsley <jarrett.billingsley@gmail.com> 2009-06-19 09:51:18 PDT --- To whom it may concern: would an "I told you so" dance here be appropriate? ;) String mixins are cute, but we need actual macros to be able to do things like this more generally. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 19, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 --- Comment #2 from Jarrett Billingsley <jarrett.billingsley@gmail.com> 2009-06-19 10:21:55 PDT --- (In reply to comment #1) > To whom it may concern: would an "I told you so" dance here be appropriate? ;) > > String mixins are cute, but we need actual macros to be able to do things like this more generally. For those interested, the cause really _is_ because Foo is defined in a different module. The unaryFun template fails because ElementType.stringof yields "Foo", which isn't visible to std.functional. Even if it could compile the lambda func, the "alias typeof(mixin(testAsExpression))" line still fails because again, Foo is not accessible. That it uses ElementType.stringof also means that it will fail for just about anything other than the builtin types. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 20, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 Max Samukha <samukha@voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |samukha@voliacable.com --- Comment #3 from Max Samukha <samukha@voliacable.com> 2009-06-20 02:56:29 PDT --- Yeah, .stringof shouldn't be used there. But we still can get to the type through the alias. Changing the mixin string to enum testAsExpression = "{ ElementType "~parmName~"; return ("~fun~");}()"; should fix the bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 20, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 --- Comment #4 from Jarrett Billingsley <jarrett.billingsley@gmail.com> 2009-06-20 10:13:42 PDT --- (In reply to comment #3) > Yeah, .stringof shouldn't be used there. But we still can get to the type > through the alias. Changing the mixin string to > enum testAsExpression = "{ ElementType "~parmName~"; return ("~fun~");}()"; > should fix the bug. I can confirm that does work. That being said, the amount of acrobatics that had to be performed to make the templates involved not directly refer to the type at hand is somewhat frightening. It reminds me of implementing something by using lambdas several layers deep. This stuff probably has a limit, if not in what it can do, then in the cognitive load on the programmers using it. Too bad macros were scrapped for D2, huh? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 20, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 --- Comment #5 from Max Samukha <samukha@voliacable.com> 2009-06-20 12:18:39 PDT --- Bad enough -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 04, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |andrei@metalanguage.com Resolution| |FIXED --- Comment #6 from Andrei Alexandrescu <andrei@metalanguage.com> 2009-07-03 23:24:17 PDT --- Fixed, will come with the next release. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 09, 2009 [Issue 3081] unaryFun can't be used to get element out of struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha@yahoo.com | http://d.puremagic.com/issues/show_bug.cgi?id=3081 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2009-07-09 02:57:27 PDT --- Fixed dmd 2.031 -- 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