Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 22, 2014 CT info about class' children | ||||
---|---|---|---|---|
| ||||
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. |
April 22, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | 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 |
April 22, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Any way to do it without patching druntime? |
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | On 22/04/14 22:50, Yuriy wrote: > Any way to do it without patching druntime? Not that I know of. -- /Jacob Carlborg |
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | "Yuriy" wrote in message news:duumbptvbqwknucxgaxi@forum.dlang.org... > Any way to do it without patching druntime? Patch the compiler. |
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Wed, 23 Apr 2014 02:34:52 -0400, Daniel Murphy <yebbliesnospam@gmail.com> wrote:
> "Yuriy" wrote in message news:duumbptvbqwknucxgaxi@forum.dlang.org...
>> Any way to do it without patching druntime?
>
> Patch the compiler.
Did you type that with a straight face?
-Steve
|
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | "Steven Schveighoffer" wrote in message news:op.xerz7jcceav7ka@stevens-macbook-pro-2.local... > Did you type that with a straight face? :) |
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | 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 |
April 23, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuriy | 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/775
Looks fairly interesting, because it partly solves the issue to allow custom rtinfo.
|
April 24, 2014 Re: CT info about class' children | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | 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 |
Copyright © 1999-2021 by the D Language Foundation