Jump to page: 1 29  
Page
Thread overview
Compiler patch for runtime reflection
Oct 21, 2011
Vladimir Panteleev
Oct 22, 2011
Robert Jacques
Oct 22, 2011
Robert Jacques
Oct 22, 2011
Jacob Carlborg
Oct 21, 2011
Daniel Gibson
Oct 22, 2011
Robert Jacques
Oct 22, 2011
Vladimir Panteleev
Oct 22, 2011
Andrej Mitrovic
Oct 22, 2011
Vladimir Panteleev
Oct 23, 2011
Vladimir Panteleev
Oct 23, 2011
Timon Gehr
Oct 23, 2011
Timon Gehr
Oct 23, 2011
Vladimir Panteleev
Oct 23, 2011
Vladimir Panteleev
Oct 23, 2011
Robert Jacques
Oct 23, 2011
Robert Jacques
Oct 23, 2011
Jacob Carlborg
Oct 23, 2011
Robert Jacques
Oct 24, 2011
Jacob Carlborg
Oct 24, 2011
Robert Jacques
Oct 24, 2011
Jacob Carlborg
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Jacob Carlborg
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Timon Gehr
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Ary Manzana
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Jacob Carlborg
Oct 26, 2011
Robert Jacques
Oct 26, 2011
Kapps
Oct 26, 2011
Jacob Carlborg
Oct 24, 2011
Daniel Gibson
Oct 25, 2011
Robert Jacques
Oct 26, 2011
Kapps
Oct 26, 2011
Jacob Carlborg
Jan 23, 2012
sclytrack
Oct 22, 2011
Daniel Gibson
Oct 22, 2011
Robert Jacques
Oct 22, 2011
foobar
Oct 22, 2011
Robert Jacques
Oct 22, 2011
foobar
Oct 22, 2011
Robert Jacques
Oct 24, 2011
deadalnix
Oct 24, 2011
Robert Jacques
Oct 22, 2011
Jacob Carlborg
Oct 23, 2011
Walter Bright
Oct 24, 2011
Jacob Carlborg
Oct 25, 2011
Jonny Dee
Oct 25, 2011
Gor Gyolchanyan
Oct 25, 2011
Robert Jacques
Oct 25, 2011
Jonny Dee
Oct 26, 2011
Robert Jacques
Oct 26, 2011
Jonny Dee
Oct 26, 2011
Jacob Carlborg
Oct 26, 2011
Adam Wilson
Oct 27, 2011
Jacob Carlborg
Oct 27, 2011
Adam Wilson
Oct 28, 2011
Jacob Carlborg
Oct 28, 2011
Gor Gyolchanyan
Oct 28, 2011
Adam Wilson
Oct 29, 2011
Jacob Carlborg
Oct 29, 2011
Adam Wilson
Oct 30, 2011
Jacob Carlborg
Oct 31, 2011
Mehrdad
Oct 27, 2011
Robert Jacques
Oct 27, 2011
Robert Jacques
October 21, 2011
Hi,

Igor Stepanov has created a patch for DMD and Druntime which adds RTTI information for class and struct members.

Example:

import std.stdio;

class Foo
{
	static void PrintHello()
	{
		writeln("Hello");
	}
}
void main()
{
	auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
	assert(info.name == "PrintHello");
	auto print = cast(void function())info.pointer;
	print(); //prints "Hello"
}

While the inclusion of such functionality into the language remains a disputed matter, would anyone be interested in an unofficial patch for this?

Walter: would it be okay if the compiler changes were published as a GitHub fork, or should we stick to patches?

-- 
Best regards,
 Vladimir                            mailto:vladimir@thecybershadow.net
October 21, 2011
On 21-10-2011 21:07, Vladimir Panteleev wrote:
> Hi,
>
> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
> information for class and struct members.
>
> Example:
>
> import std.stdio;
>
> class Foo
> {
> static void PrintHello()
> {
> writeln("Hello");
> }
> }
> void main()
> {
> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
> assert(info.name == "PrintHello");
> auto print = cast(void function())info.pointer;
> print(); //prints "Hello"
> }

Absolutely awesome!

>
> While the inclusion of such functionality into the language remains a
> disputed matter, would anyone be interested in an unofficial patch for
> this?

Yes, very much. I would recommend setting up a fork on GitHub, and then adding it to a branch, e.g. 'reflection', if it's not going to be included in mainline DMD.

>
> Walter: would it be okay if the compiler changes were published as a
> GitHub fork, or should we stick to patches?
>

- Alex
October 21, 2011
Am 21.10.2011 21:07, schrieb Vladimir Panteleev:
> Hi,
>
> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
> information for class and struct members.
>
> Example:
>
> import std.stdio;
>
> class Foo
> {
> static void PrintHello()
> {
> writeln("Hello");
> }
> }
> void main()
> {
> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
> assert(info.name == "PrintHello");
> auto print = cast(void function())info.pointer;
> print(); //prints "Hello"
> }
>
> While the inclusion of such functionality into the language remains a
> disputed matter, would anyone be interested in an unofficial patch for
> this?
>
> Walter: would it be okay if the compiler changes were published as a
> GitHub fork, or should we stick to patches?
>

I'd love to see proper runtime reflection support in D, including functionality to get information about available methods (their name and parameters) and a way to call them.
Something that is close to what Java offers would be great.

BTW: I don't really see the problem with providing this information (overhead-wise) - the information needs to be available once per class/struct, but objects of classes just need one pointer to it (other types don't even need that because they're not polymorphic and - like methods of structs - the address of the information is known at compile-time).

Cheers,
- Daniel
October 22, 2011
On Fri, 21 Oct 2011 17:15:02 -0400, Alex Rønne Petersen <xtzgzorex@gmail.com> wrote:

> On 21-10-2011 21:07, Vladimir Panteleev wrote:
>> Hi,
>>
>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>> information for class and struct members.
>>
>> Example:
>>
>> import std.stdio;
>>
>> class Foo
>> {
>> static void PrintHello()
>> {
>> writeln("Hello");
>> }
>> }
>> void main()
>> {
>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>> assert(info.name == "PrintHello");
>> auto print = cast(void function())info.pointer;
>> print(); //prints "Hello"
>> }
>
> Absolutely awesome!
>
>>
>> While the inclusion of such functionality into the language remains a
>> disputed matter, would anyone be interested in an unofficial patch for
>> this?
>
> Yes, very much. I would recommend setting up a fork on GitHub, and then
> adding it to a branch, e.g. 'reflection', if it's not going to be
> included in mainline DMD.

Really? A runtime reflection system has been on the review queue for over six months and I've brought the subject up on the newsgroup. I've received zero feedback. So while I'm sure everyone want to check RTTI off the D features list, I've not seen much real interest in it.
October 22, 2011
On Fri, 21 Oct 2011 17:23:17 -0400, Daniel Gibson <metalcaedes@gmail.com> wrote:
> Am 21.10.2011 21:07, schrieb Vladimir Panteleev:
>> Hi,
>>
>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>> information for class and struct members.
>>
>> Example:
>>
>> import std.stdio;
>>
>> class Foo
>> {
>> static void PrintHello()
>> {
>> writeln("Hello");
>> }
>> }
>> void main()
>> {
>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>> assert(info.name == "PrintHello");
>> auto print = cast(void function())info.pointer;
>> print(); //prints "Hello"
>> }
>>
>> While the inclusion of such functionality into the language remains a
>> disputed matter, would anyone be interested in an unofficial patch for
>> this?
>>
>> Walter: would it be okay if the compiler changes were published as a
>> GitHub fork, or should we stick to patches?
>>
>
> I'd love to see proper runtime reflection support in D, including
> functionality to get information about available methods (their name and
> parameters) and a way to call them.

What do you mean by their 'parameters'? What about overloads? Attributes? Arguments? Argument attributes?

> Something that is close to what Java offers would be great.

And what, exactly does JAVA offer? What works? What doesn't work? What's missing?

> BTW: I don't really see the problem with providing this information
> (overhead-wise) - the information needs to be available once per
> class/struct, but objects of classes just need one pointer to it (other
> types don't even need that because they're not polymorphic and - like
> methods of structs - the address of the information is known at
> compile-time).

1) Unused information is simply bloat: it increases exe size, slows the exe down and increases the runtime memory footprint.
2) On a lot of systems (i.e. consoles, embedded, smart phones, tablets) memory and disk space are both highly constrained resources that you don't want to waste.
3) RTTI provides a back-door into a code-base; one that for many reasons you may want to keep closed.
October 22, 2011
On 22-10-2011 05:48, Robert Jacques wrote:
> On Fri, 21 Oct 2011 17:23:17 -0400, Daniel Gibson
> <metalcaedes@gmail.com> wrote:
>> Am 21.10.2011 21:07, schrieb Vladimir Panteleev:
>>> Hi,
>>>
>>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>>> information for class and struct members.
>>>
>>> Example:
>>>
>>> import std.stdio;
>>>
>>> class Foo
>>> {
>>> static void PrintHello()
>>> {
>>> writeln("Hello");
>>> }
>>> }
>>> void main()
>>> {
>>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>>> assert(info.name == "PrintHello");
>>> auto print = cast(void function())info.pointer;
>>> print(); //prints "Hello"
>>> }
>>>
>>> While the inclusion of such functionality into the language remains a
>>> disputed matter, would anyone be interested in an unofficial patch for
>>> this?
>>>
>>> Walter: would it be okay if the compiler changes were published as a
>>> GitHub fork, or should we stick to patches?
>>>
>>
>> I'd love to see proper runtime reflection support in D, including
>> functionality to get information about available methods (their name and
>> parameters) and a way to call them.
>
> What do you mean by their 'parameters'? What about overloads?
> Attributes? Arguments? Argument attributes?
>
>> Something that is close to what Java offers would be great.
>
> And what, exactly does JAVA offer? What works? What doesn't work? What's
> missing?
>
>> BTW: I don't really see the problem with providing this information
>> (overhead-wise) - the information needs to be available once per
>> class/struct, but objects of classes just need one pointer to it (other
>> types don't even need that because they're not polymorphic and - like
>> methods of structs - the address of the information is known at
>> compile-time).
>
> 1) Unused information is simply bloat: it increases exe size, slows the
> exe down and increases the runtime memory footprint.
> 2) On a lot of systems (i.e. consoles, embedded, smart phones, tablets)
> memory and disk space are both highly constrained resources that you
> don't want to waste.
> 3) RTTI provides a back-door into a code-base; one that for many reasons
> you may want to keep closed.

You could just introduce a -reflection switch to include reflection information.

- Alex
October 22, 2011
On 22-10-2011 05:36, Robert Jacques wrote:
> On Fri, 21 Oct 2011 17:15:02 -0400, Alex Rønne Petersen
> <xtzgzorex@gmail.com> wrote:
>
>> On 21-10-2011 21:07, Vladimir Panteleev wrote:
>>> Hi,
>>>
>>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>>> information for class and struct members.
>>>
>>> Example:
>>>
>>> import std.stdio;
>>>
>>> class Foo
>>> {
>>> static void PrintHello()
>>> {
>>> writeln("Hello");
>>> }
>>> }
>>> void main()
>>> {
>>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>>> assert(info.name == "PrintHello");
>>> auto print = cast(void function())info.pointer;
>>> print(); //prints "Hello"
>>> }
>>
>> Absolutely awesome!
>>
>>>
>>> While the inclusion of such functionality into the language remains a
>>> disputed matter, would anyone be interested in an unofficial patch for
>>> this?
>>
>> Yes, very much. I would recommend setting up a fork on GitHub, and then
>> adding it to a branch, e.g. 'reflection', if it's not going to be
>> included in mainline DMD.
>
> Really? A runtime reflection system has been on the review queue for
> over six months and I've brought the subject up on the newsgroup. I've
> received zero feedback. So while I'm sure everyone want to check RTTI
> off the D features list, I've not seen much real interest in it.

I must have missed that. What should I search for to find your thread?

- Alex
October 22, 2011
Am 22.10.2011 05:48, schrieb Robert Jacques:
> On Fri, 21 Oct 2011 17:23:17 -0400, Daniel Gibson
> <metalcaedes@gmail.com> wrote:
>> Am 21.10.2011 21:07, schrieb Vladimir Panteleev:
>>> Hi,
>>>
>>> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
>>> information for class and struct members.
>>>
>>> Example:
>>>
>>> import std.stdio;
>>>
>>> class Foo
>>> {
>>> static void PrintHello()
>>> {
>>> writeln("Hello");
>>> }
>>> }
>>> void main()
>>> {
>>> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
>>> assert(info.name == "PrintHello");
>>> auto print = cast(void function())info.pointer;
>>> print(); //prints "Hello"
>>> }
>>>
>>> While the inclusion of such functionality into the language remains a
>>> disputed matter, would anyone be interested in an unofficial patch for
>>> this?
>>>
>>> Walter: would it be okay if the compiler changes were published as a
>>> GitHub fork, or should we stick to patches?
>>>
>>
>> I'd love to see proper runtime reflection support in D, including
>> functionality to get information about available methods (their name and
>> parameters) and a way to call them.
>
> What do you mean by their 'parameters'? What about overloads?
> Attributes? Arguments? Argument attributes?
>

Primarily arguments. That should help identifying overloads.
But attributes and argument attributes are needed as well.

>> Something that is close to what Java offers would be great.
>
> And what, exactly does JAVA offer? What works? What doesn't work? What's
> missing?

See
http://download.oracle.com/javase/6/docs/api/java/lang/Class.html
You can access constructors (look for one by it's parameters or get all of them), the same for methods (methods the class declares and all methods, i.e. also inherited ones), implemented interfaces, fields, ...
>
>> BTW: I don't really see the problem with providing this information
>> (overhead-wise) - the information needs to be available once per
>> class/struct, but objects of classes just need one pointer to it (other
>> types don't even need that because they're not polymorphic and - like
>> methods of structs - the address of the information is known at
>> compile-time).
>
> 1) Unused information is simply bloat: it increases exe size, slows the
> exe down and increases the runtime memory footprint.

Yeah, but (mostly) only per class, not per object (besides one pointer per object, which shouldn't be that bad and something like this seems is already there for the existing typeinfo)

> 2) On a lot of systems (i.e. consoles, embedded, smart phones, tablets)
> memory and disk space are both highly constrained resources that you
> don't want to waste.
> 3) RTTI provides a back-door into a code-base; one that for many reasons
> you may want to keep closed.

Yeah, it may make sense to be able to deactivate it.

Cheers,
- Daniel
October 22, 2011
On Sat, 22 Oct 2011 13:50:32 +0300, Alex Rønne Petersen <xtzgzorex@gmail.com> wrote:

> You could just introduce a -reflection switch to include reflection information.

As I mentioned in the previous thread on the subject, I think that ideally we should improve compile-time reflection so it's possible to generate runtime reflection information at compilation time. Something like this:

import reflection;

enum reflectionForStdStdio = generateReflectionForModule("std.stdio");

void main()
{
    reflectionForStdStdio.callFunction("writeln", "Hello, world!");
}

-- 
Best regards,
 Vladimir                            mailto:vladimir@thecybershadow.net
October 22, 2011
On 2011-10-21 21:07, Vladimir Panteleev wrote:
> Hi,
>
> Igor Stepanov has created a patch for DMD and Druntime which adds RTTI
> information for class and struct members.
>
> Example:
>
> import std.stdio;
>
> class Foo
> {
> static void PrintHello()
> {
> writeln("Hello");
> }
> }
> void main()
> {
> auto info = cast(OffsetTypeInfo_StaticMethod)Foo.classinfo.m_offTi[0];
> assert(info.name == "PrintHello");
> auto print = cast(void function())info.pointer;
> print(); //prints "Hello"
> }
>
> While the inclusion of such functionality into the language remains a
> disputed matter, would anyone be interested in an unofficial patch for
> this?
>
> Walter: would it be okay if the compiler changes were published as a
> GitHub fork, or should we stick to patches?
>

Very cool.

-- 
/Jacob Carlborg
« First   ‹ Prev
1 2 3 4 5 6 7 8 9