digitalmars.D.bugs - [Issue 2868] New: provide runtime facility for reflection. opDot compiletime dispatch facility
- d-bugmail puremagic.com (93/93) Apr 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2868
- d-bugmail puremagic.com (7/7) Apr 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2868
- d-bugmail puremagic.com (12/12) Apr 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2868
- d-bugmail puremagic.com (12/12) May 07 2010 http://d.puremagic.com/issues/show_bug.cgi?id=2868
http://d.puremagic.com/issues/show_bug.cgi?id=2868 Summary: provide runtime facility for reflection. opDot compiletime dispatch facility Product: D Version: 2.028 Platform: PC OS/Version: Windows Status: NEW Keywords: patch Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: davidl 126.com 1. modify the D2 opDot semantic from forwarding to compiletime opDot function calling 2. modify the D2 __traits(getallmembers) to return tuples. in the patch, it's currently organized as: (member_name, member_symbol) pair Thus, by the 1st change we can have following code working: import std.stdio; class c { B opDot(U:immutable(char)[], T...)(U methodname, T t) { writefln("god it works ", methodname); return new B(); } void opAdd(int j) { } void test() { } } class B { int i; B opAssign(int k){ i=k; return this; } } void extmethod(c v,int j){writefln("extmenthod!");} char[] v1; void func(char[] v, ...){} void main() { c v=new c; v.opDot("jesus", 3,4); v.test(); v.dynamicmethod(3,4); //v.qq(1,2) = 5; writefln((v.qq(1,2) = 5).i); v.extmethod(3); } By the second change we can have the following code working: import std.stdio; class D { int tt; alias tt this; this() { } ~this() { } int foo(int) { tt++;writefln("god you called me?");return 0; } void foo() { } int vvv; } class M:D { void callfunc() { pragma(msg, __traits(allMembers, D)[0]); pragma(msg, __traits(allMembers, D)[2]); pragma(msg, __traits(allMembers, D)[6]); __traits(allMembers, D)[7](1); writefln("tt should be 1 now ",tt); } } void main() { auto b = ["__ctor","__dtor","foo","toString","toHash","opCmp","opEquals","Monitor","factory"]; M subd= new M; subd.callfunc(); writefln(subd.tt); } The second change provides richer functionality while we can still achieve the old result by templates wrapping the __traits. original opDot semantic can be simulated by the 1st and 2nd change together. Thus I think the semantic change provides richer functionality while on the other hand we can still mock the old behavior. --
Apr 21 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2868 Created an attachment (id=333) --> (http://d.puremagic.com/issues/attachment.cgi?id=333&action=view) the patch for the two semantic proposals here's the patch against dmd2.028 --
Apr 21 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2868 davidl 126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Summary|provide runtime facility for|provide runtime facility for |reflection. opDot |reflection. opDot |compiletime dispatch |compiletime dispatch |facility |facility It's an enhancement. --
Apr 21 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2868 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |FIXED opDispatch was added in DMD2.037. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 07 2010