digitalmars.D - CT info about class' children
- Yuriy (21/21) Apr 22 2014 Hello, is there a way of getting CT info of a class' children?
- Jacob Carlborg (8/9) Apr 22 2014 Not in a pretty way but I think this should work:
- Yuriy (1/1) Apr 22 2014 Any way to do it without patching druntime?
- Jacob Carlborg (4/5) Apr 22 2014 Not that I know of.
- Daniel Murphy (2/3) Apr 22 2014 Patch the compiler.
- Steven Schveighoffer (4/7) Apr 23 2014 Did you type that with a straight face?
- Daniel Murphy (3/4) Apr 23 2014 :)
- Yuriy (3/3) Apr 23 2014 Ok, i've added a pull request to be discussed. It expands RTInfo
- Martin Nowak (3/6) Apr 23 2014 Looks fairly interesting, because it partly solves the issue to
- Jacob Carlborg (8/10) Apr 23 2014 I don't like this solution for custom RTInfo. It requires you to change
- Yuriy (5/15) Apr 23 2014 I guess this could be done without modifying the compiler, just
- Yuriy (1/5) Apr 23 2014 But as an additional feature such UDA might be useful.
- Yuriy (5/5) Apr 23 2014 Also, this whole thing is not only about RT registration, it may
- Martin Nowak (3/13) Apr 24 2014 This is technically almost identical to having a special _RTInfo
- Yuriy (3/3) Apr 24 2014 rtInfo through attributes implemented. Jacob, have i done it the
Hello, is there a way of getting CT info of a class' children? If no, what do you think of a new feature for DMD: template this static ctors/dtors: class A { static this(this T)() { writeln("static this(", T.stringof, ")"); } } class B : A { } would output: static this(A) static this(B) how it works: when instantiating (shared) static ctors/dtors of class C, DMD will look for template_this_static_ctors/dtors in C, and all of it's superclasses, instantiating each with C as this, and adding such instances to C as regular static ctors/dtors.
Apr 22 2014
On 2014-04-22 11:20, Yuriy wrote:Hello, is there a way of getting CT info of a class' children?Not in a pretty way but I think this should work: * Implement a custom RTInfo in object.d in druntime. This template will be instantiated with all user defined types * For each type that is a class, check all it's parents via __traits * If a parent is matching what you're looking for then you found a child -- /Jacob Carlborg
Apr 22 2014
On 22/04/14 22:50, Yuriy wrote:Any way to do it without patching druntime?Not that I know of. -- /Jacob Carlborg
Apr 22 2014
"Yuriy" wrote in message news:duumbptvbqwknucxgaxi forum.dlang.org...Any way to do it without patching druntime?Patch the compiler.
Apr 22 2014
On Wed, 23 Apr 2014 02:34:52 -0400, Daniel Murphy <yebbliesnospam gmail.com> wrote:"Yuriy" wrote in message news:duumbptvbqwknucxgaxi forum.dlang.org...Did you type that with a straight face? -SteveAny way to do it without patching druntime?Patch the compiler.
Apr 23 2014
"Steven Schveighoffer" wrote in message news:op.xerz7jcceav7ka stevens-macbook-pro-2.local...Did you type that with a straight face?:)
Apr 23 2014
Ok, i've added a pull request to be discussed. It expands RTInfo capability as Jacob suggested. What do you think? https://github.com/D-Programming-Language/druntime/pull/775
Apr 23 2014
On Wednesday, 23 April 2014 at 16:06:58 UTC, Yuriy wrote:Ok, i've added a pull request to be discussed. It expands RTInfo capability as Jacob suggested. What do you think? https://github.com/D-Programming-Language/druntime/pull/775Looks fairly interesting, because it partly solves the issue to allow custom rtinfo.
Apr 23 2014
On 24/04/14 00:29, Martin Nowak wrote:Looks fairly interesting, because it partly solves the issue to allow custom rtinfo.I don't like this solution for custom RTInfo. It requires you to change your type. I would rather modify the compiler to do something like this: * Add a UDA to druntime: "core.attributes.rtInfo" * If any template has the core.attributes.rtInfo UDA attached to itself, instantiate that as is done with core.RTInfo -- /Jacob Carlborg
Apr 23 2014
On Thursday, 24 April 2014 at 06:08:11 UTC, Jacob Carlborg wrote:On 24/04/14 00:29, Martin Nowak wrote:I guess this could be done without modifying the compiler, just extend RTInfo(T) to support this UDA, but there's a problem with attributes. They don't propagate to class' children, thus they can't solve the main question of this topic.Looks fairly interesting, because it partly solves the issue to allow custom rtinfo.I don't like this solution for custom RTInfo. It requires you to change your type. I would rather modify the compiler to do something like this: * Add a UDA to druntime: "core.attributes.rtInfo" * If any template has the core.attributes.rtInfo UDA attached to itself, instantiate that as is done with core.RTInfo
Apr 23 2014
I guess this could be done without modifying the compiler, just extend RTInfo(T) to support this UDA, but there's a problem with attributes. They don't propagate to class' children, thus they can't solve the main question of this topic.But as an additional feature such UDA might be useful.
Apr 23 2014
Also, this whole thing is not only about RT registration, it may be used differently. The next usage that comes to mind after RT is validating proper inheritance. E.g. Some root class wants it's subclasses to always have a default ctor available, which again can be verified in CT.
Apr 23 2014
On Thursday, 24 April 2014 at 06:08:11 UTC, Jacob Carlborg wrote:On 24/04/14 00:29, Martin Nowak wrote:This is technically almost identical to having a special _RTInfo template within the type, but it's a cleaner solution.Looks fairly interesting, because it partly solves the issue to allow custom rtinfo.I don't like this solution for custom RTInfo. It requires you to change your type. I would rather modify the compiler to do something like this: * Add a UDA to druntime: "core.attributes.rtInfo" * If any template has the core.attributes.rtInfo UDA attached to itself, instantiate that as is done with core.RTInfo
Apr 24 2014
rtInfo through attributes implemented. Jacob, have i done it the way you wanted? https://github.com/D-Programming-Language/druntime/pull/775#issuecomment-41278520
Apr 24 2014