Re: CT info about class' children

2014-04-24 Thread Jacob Carlborg via Digitalmars-d

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


Re: CT info about class' children

2014-04-24 Thread Yuriy via Digitalmars-d

On Thursday, 24 April 2014 at 06:08:11 UTC, Jacob Carlborg wrote:

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


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.


Re: CT info about class' children

2014-04-24 Thread Yuriy via Digitalmars-d
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.


Re: CT info about class' children

2014-04-24 Thread Yuriy via Digitalmars-d
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.


Re: CT info about class' children

2014-04-24 Thread Martin Nowak via Digitalmars-d

On Thursday, 24 April 2014 at 06:08:11 UTC, Jacob Carlborg wrote:

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


This is technically almost identical to having a special _RTInfo 
template within the type, but it's a cleaner solution.


Re: CT info about class' children

2014-04-24 Thread Yuriy via Digitalmars-d
rtInfo through attributes implemented. Jacob, have i done it the 
way you wanted?


https://github.com/D-Programming-Language/druntime/pull/775#issuecomment-41278520


Re: CT info about class' children

2014-04-23 Thread Jacob Carlborg via Digitalmars-d

On 22/04/14 22:50, Yuriy wrote:

Any way to do it without patching druntime?


Not that I know of.

--
/Jacob Carlborg


Re: CT info about class' children

2014-04-23 Thread Daniel Murphy via Digitalmars-d
Yuriy  wrote in message news:duumbptvbqwknucxg...@forum.dlang.org... 


Any way to do it without patching druntime?


Patch the compiler.


Re: CT info about class' children

2014-04-23 Thread Steven Schveighoffer via Digitalmars-d
On Wed, 23 Apr 2014 02:34:52 -0400, Daniel Murphy  
yebbliesnos...@gmail.com wrote:



Yuriy  wrote in message news:duumbptvbqwknucxg...@forum.dlang.org...

Any way to do it without patching druntime?


Patch the compiler.


Did you type that with a straight face?

-Steve


Re: CT info about class' children

2014-04-23 Thread Daniel Murphy via Digitalmars-d
Steven Schveighoffer  wrote in message 
news:op.xerz7jcceav7ka@stevens-macbook-pro-2.local...



Did you type that with a straight face?


:) 



Re: CT info about class' children

2014-04-23 Thread Yuriy via Digitalmars-d
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


Re: CT info about class' children

2014-04-23 Thread Martin Nowak via Digitalmars-d

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.


Re: CT info about class' children

2014-04-22 Thread Jacob Carlborg via Digitalmars-d

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


Re: CT info about class' children

2014-04-22 Thread Yuriy via Digitalmars-d

Any way to do it without patching druntime?