www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Igor Stepanov's runtime reflection patch

reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
Igor Stepanov has finished his runtime reflection patch, 
announced here a while ago. [1]

DMD patch against commit c50eb5f (from December 31): 
http://j.mp/xdI0hb
Druntime Github fork: https://github.com/IgorStepanov/druntime

User classes can declare a getMembers method, which becomes 
available in the classinfo. The patch adds implicit generation of 
getMembers information for all classes and structures, which do 
not declare the method explicitly.

Usage is simple: YourClass.classinfo.getMembers("field") returns 
a list of fields with that name (MemberInfo array). Use null to 
get all fields. This also works for modules and enumerations.

The patch also adds linkage and argument information to function 
TypeInfo.

An example of what would be possible with this patch: call 
arbitrary methods by name and a Variant array as parameters, and 
obtaining the result as a Variant.

Igor has asked about the potential of this patch to be included 
into DMD. I imagine that the consensus would be that it should at 
least be enabled (or disabled) with a compiler switch, or 
attribute in the source code.

  [1]: http://j.mp/wZLCDb
Jan 12 2012
next sibling parent reply Trass3r <un known.com> writes:
 DMD patch against commit c50eb5f (from December 31): http://j.mp/xdI0hb
 Druntime Github fork: https://github.com/IgorStepanov/druntime

Why the heck isn't the dmd patch a fork as well?
Jan 12 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-01-13 05:33, Brad Roberts wrote:
 On 1/12/2012 7:48 PM, Vladimir Panteleev wrote:
 On Friday, 13 January 2012 at 01:52:04 UTC, Trass3r wrote:
 DMD patch against commit c50eb5f (from December 31): http://j.mp/xdI0hb
 Druntime Github fork: https://github.com/IgorStepanov/druntime

Why the heck isn't the dmd patch a fork as well?

Walter said[1] that compiler modifications that change the language are better-off distributed as patches. [1]: http://j.mp/w6PnwF

He meant not a language fork. And by patch, I'm sure he included pull requests. Terminology differences.

I see no reason why Walter would want a patch instead of a pull request. -- /Jacob Carlborg
Jan 12 2012
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 13 January 2012 at 01:52:04 UTC, Trass3r wrote:
 DMD patch against commit c50eb5f (from December 31): 
 http://j.mp/xdI0hb
 Druntime Github fork: https://github.com/IgorStepanov/druntime

Why the heck isn't the dmd patch a fork as well?

Walter said[1] that compiler modifications that change the language are better-off distributed as patches. [1]: http://j.mp/w6PnwF
Jan 12 2012
prev sibling next sibling parent Brad Roberts <braddr puremagic.com> writes:
On 1/12/2012 7:48 PM, Vladimir Panteleev wrote:
 On Friday, 13 January 2012 at 01:52:04 UTC, Trass3r wrote:
 DMD patch against commit c50eb5f (from December 31): http://j.mp/xdI0hb
 Druntime Github fork: https://github.com/IgorStepanov/druntime

Why the heck isn't the dmd patch a fork as well?

Walter said[1] that compiler modifications that change the language are better-off distributed as patches. [1]: http://j.mp/w6PnwF

He meant not a language fork. And by patch, I'm sure he included pull requests. Terminology differences.
Jan 12 2012
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-01-13 00:50, Vladimir Panteleev wrote:
 Igor Stepanov has finished his runtime reflection patch, announced here
 a while ago. [1]

 DMD patch against commit c50eb5f (from December 31): http://j.mp/xdI0hb
 Druntime Github fork: https://github.com/IgorStepanov/druntime

 User classes can declare a getMembers method, which becomes available in
 the classinfo. The patch adds implicit generation of getMembers
 information for all classes and structures, which do not declare the
 method explicitly.

 Usage is simple: YourClass.classinfo.getMembers("field") returns a list
 of fields with that name (MemberInfo array). Use null to get all fields.
 This also works for modules and enumerations.

 The patch also adds linkage and argument information to function TypeInfo.

 An example of what would be possible with this patch: call arbitrary
 methods by name and a Variant array as parameters, and obtaining the
 result as a Variant.

 Igor has asked about the potential of this patch to be included into
 DMD. I imagine that the consensus would be that it should at least be
 enabled (or disabled) with a compiler switch, or attribute in the source
 code.

 [1]: http://j.mp/wZLCDb

Cool, but do we really want all these enums (Linkage, StorageClass and so on) at global scope? -- /Jacob Carlborg
Jan 12 2012