Ok, my proposal is up, I'm looking forward to feedback. *fingers crossed* (Cristi Cobzarenco) Pofile: http://www.google.com/profiles/cristi.cobzarenco
On 30 March 2011 17:03, Cristi Cobzarenco <[email protected]>wrote: > Hmmm, the only problem with this is that we would have to require the > library users to do this to their functions. Thanks for the suggestion but > I'll stick with .mangleof sorting. > (Cristi Cobzarenco) > Pofile: http://www.google.com/profiles/cristi.cobzarenco > > > On 30 March 2011 16:49, Andrej Mitrovic <[email protected]>wrote: > >> Maybe OT, but here's some hackish wizardry you can do with classes: >> >> class Test >> { >> int value; >> >> this(int x) >> { >> value = x; >> } >> } >> >> ref Test foo(Test t ...) >> { >> return tuple(t)[0]; >> } >> >> void main() >> { >> auto result = foo(4); >> assert(result.value == 4); >> } >> >> The Tuple is used to trick DMD into escaping the local `t` reference. >> This won't work with structs. And `t` should be constructed on the >> stack, but it seems the destructor gets called only after the exit >> from main. The docs do say that construction of classes in variadic >> arguments depend on the implementation. >> >> I asked on the newsgroups whether Typesafe Variadic Functions >> automatically calling a constructor was a good thing at all. Read >> about this feature here under "Typesafe Variadic Functions": >> http://www.digitalmars.com/d/2.0/function.html >> > >
