digitalmars.D - Making TypeInfo.next() return a const(TypeInfo) was a bad idea
- Benjamin Thaut (15/15) Oct 14 2012 Because you are now no longer able to do stuff like this:
- =?ISO-8859-15?Q?Alex_R=F8nne_Petersen?= (9/24) Oct 14 2012 None, to be honest. I can only recommend going with a cast hack or
- Jonathan M Davis (14/16) Oct 14 2012 If we really need Rebindable in druntime, then we can simply move it to=
- Mehrdad (1/1) Oct 14 2012 http://stackoverflow.com/questions/12506338
- Jonathan M Davis (4/5) Oct 14 2012 Yes. The problem is that he's trying to do something in druntime, and
- Rainer Schuetze (17/30) Oct 14 2012 That's the general problem of non-rebindable const references which is a...
Because you are now no longer able to do stuff like this: void log(...) { auto t = _arguments[0]; while(some condition) { t = t.next(); } } To be actually able to use TypeInfo.next you will now need the ConstRef (hack) from phobos. Afaik there is no such thing in druntime which makes working with TypeInfo.next within druntime a real pita. Any suggestions? Kind Regards Benjamin Thaut
Oct 14 2012
On 14-10-2012 12:19, Benjamin Thaut wrote:Because you are now no longer able to do stuff like this: void log(...) { auto t = _arguments[0]; while(some condition) { t = t.next(); } } To be actually able to use TypeInfo.next you will now need the ConstRef (hack) from phobos. Afaik there is no such thing in druntime which makes working with TypeInfo.next within druntime a real pita. Any suggestions? Kind Regards Benjamin ThautNone, to be honest. I can only recommend going with a cast hack or something similar for now. But this is a problem we *must* solve. It is something I also ran into often while hacking on druntime. -- Alex Rønne Petersen alex lycus.org http://lycus.org
Oct 14 2012
On Monday, October 15, 2012 02:20:23 Alex R=C3=B8nne Petersen wrote:But this is a problem we *must* solve. It is something I also ran int=ooften while hacking on druntime.If we really need Rebindable in druntime, then we can simply move it to= an=20 appropriate place in druntime and alias std.typecons.Rebindable to it. core.time exists specifically because druntime needed some of the datet= ime stuff=20 (most particularly the duration stuff). Otherwise, everything in it wou= ld be in=20 std.datetime (where it was when originally proposed). We can do the same with other constructs if we really need to. We just = don't=20 want to be moving them to druntime if we don't actually need to. - Jonathan M Davis
Oct 14 2012
On Monday, October 15, 2012 08:44:51 Mehrdad wrote:http://stackoverflow.com/questions/12506338Yes. The problem is that he's trying to do something in druntime, and Rebindable is declared in Phobos. - Jonathan M Davis
Oct 14 2012
On 10/14/2012 12:19 PM, Benjamin Thaut wrote:Because you are now no longer able to do stuff like this: void log(...) { auto t = _arguments[0]; while(some condition) { t = t.next(); } } To be actually able to use TypeInfo.next you will now need the ConstRef (hack) from phobos. Afaik there is no such thing in druntime which makes working with TypeInfo.next within druntime a real pita.That's the general problem of non-rebindable const references which is a real pita. There has been a pull request to implement it (https://github.com/D-Programming-Language/dmd/pull/3) but unfortunately it never made it into the compiler.Any suggestions?You could create a recursive function hoping for tail-recursion-optimization and inlining: void log(...) { static const(TypeInfo) drillInto(const(TypeInfo) t) { if(some condition) return drillInto(t.next()); return t; } auto t = drillInto(_arguments[0]); }
Oct 14 2012