Compiler patch for runtime reflection

Jacob Carlborg doob at me.com
Sun Oct 23 10:48:03 PDT 2011


On 2011-10-23 18:03, Robert Jacques wrote:
> On Sun, 23 Oct 2011 07:06:42 -0400, Timon Gehr <timon.gehr at gmx.ch> wrote:
> [snip]
>> The module can generate RTTI for all types recursively from the starting
>> point iff that information is statically available. It does not have to
>> be. A module that comes as .di + static library binary could return a
>> reference to a private class that has a publicly exported base class.
>> How would you generate RTTI for a statically invisible class?
>
> You're not supposed to be able to. Runtime reflection should only apply
> to public data members.

It's not enough. Take this for example:

class Foo < ActiveRecord::Base
     before_save :bar

     private

     def bar
     end
end

The above code is an example from Ruby on Rails. The "before_save" call 
sets up a callback, "bar", that will called before saving the model. The 
callback method will be called using reflection.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list