digitalmars.D.bugs - [Issue 1364] New: 2.003 traits within loop
- d-bugmail puremagic.com (29/29) Jul 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1364
- Jarrett Billingsley (4/6) Jul 23 2007 Isn't that supposed to be __traits(getMember, d, "t") ? Which entirely
- BCS (5/36) Jul 23 2007 The issue might be that the foreach is a run time foreach and the inner ...
- d-bugmail puremagic.com (13/13) Jul 24 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1364
- d-bugmail puremagic.com (10/10) Sep 03 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1364
http://d.puremagic.com/issues/show_bug.cgi?id=1364
Summary: 2.003 traits within loop
Product: D
Version: 2.002
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: Daniel919 web.de
import std.stdio;
class D
{
this() { }
~this() { }
void foo() { }
int foo(int) { return 0; }
int x;
}
void main()
{
D d = new D;
foreach (t; __traits(allMembers, typeof(d)))
writefln(typeid(typeof(__traits(getMember, d, t))));
}
(17): Error: string expected as second argument
--
Jul 23 2007
<d-bugmail puremagic.com> wrote in message news:bug-1364-3 http.d.puremagic.com/issues/...http://d.puremagic.com/issues/show_bug.cgi?id=1364writefln(typeid(typeof(__traits(getMember, d, t))));Isn't that supposed to be __traits(getMember, d, "t") ? Which entirely makes sense given the error message..
Jul 23 2007
Reply to d-bugmail puremagic.com,
http://d.puremagic.com/issues/show_bug.cgi?id=1364
Summary: 2.003 traits within loop
Product: D
Version: 2.002
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: Daniel919 web.de
import std.stdio;
class D
{
this() { }
~this() { }
void foo() { }
int foo(int) { return 0; }
int x;
}
void main()
{
D d = new D;
foreach (t; __traits(allMembers, typeof(d)))
writefln(typeid(typeof(__traits(getMember, d, t))));
}
(17): Error: string expected as second argument
The issue might be that the foreach is a run time foreach and the inner
__traits
needs a string literal. Some sort of array-to-tuple magic is needed. This
might end up looing somthing like this:
mixin(CTFEarrayToTuple(__traits(allMembers, typeof(d))))
Jul 23 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1364
Daniel919 web.de changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |1298
Nazo Humei: On IRC I was told it should work.
The foreach should be "expanded" at compile time to:
writefln(typeid(typeof(__traits(getMember, d, "foo"))));
writefln(typeid(typeof(__traits(getMember, d, "x"))));
...
--
Jul 24 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1364
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
The problem is that 't' is a runtime variable, not a string literal. When D
gets a static foreach, this kind of program will work.
--
Sep 03 2007









"Jarrett Billingsley" <kb3ctd2 yahoo.com> 