Hello,
Current reflection implementation (https://github.com/matus-chochlik/clang ) does not support reflecting functions and ClosureTypes. Is there a plan to enable such functionality? What will be possible? - reflecting function parameters, list of captures in closure, local variables?
In particular, I’m looking to solve very common problem of discrete-event DSLs: modeling combinatorial processes. In combinatorial process output is a pure function of inputs, so if some input changes output must be recalculated. If a combinatorial process is modeled with C++ function you will need somehow extract list of variables used (read) in this function. In some languages this is possible with introspection, for example in Python. MyHDL http://myhdl.org/ is a discrete-event modeling library for Python built using introspection, decorators and coroutines.
Unfortunately, there is no way in C++ to extract variables that are read in some particular function. So C++ DSL user has to specify such “lists of inputs” explicitly.
For example in SystemC (http://accellera.org/downloads/standards/systemc) I can model two-input multiplexer this way (with C++03):
sc_signal <T> in0, in1, out; // sc_signal models a “wire”
sc_signal <bool> sel;
void mux() { out = sel ? in0 : in1; } // function that models mux behaviour
SC_METHOD(mux); // Creates a process (registers a function in discrete-event scheduler)
sensitive << in0 << in1 << sel; // sets a “sensitivity list” ( ~ a list of inputs ) for created process
As you may notice this is quite verbose. And error-prone: you can easily forget to specify some input in sensitivity list and have very hard to debug behavior.
So I’m researching if there is a way to invent a better syntax using lambdas and reflection.
Hello,
Current reflection implementation (https://github.com/matus-chochlik/clang ) does not support reflecting functions and ClosureTypes. Is there a plan to enable such functionality? What will be possible? - reflecting function parameters, list of captures in closure, local variables?
In particular, I’m looking to solve very common problem of discrete-event DSLs: modeling combinatorial processes. In combinatorial process output is a pure function of inputs, so if some input changes output must be recalculated. If a combinatorial process is modeled with C++ function you will need somehow extract list of variables used (read) in this function. In some languages this is possible with introspection, for example in Python. MyHDL http://myhdl.org/ is a discrete-event modeling library for Python built using introspection, decorators and coroutines.
Unfortunately, there is no way in C++ to extract variables that are read in some particular function. So C++ DSL user has to specify such “lists of inputs” explicitly.
For example in SystemC (http://accellera.org/downloads/standards/systemc) I can model two-input multiplexer this way (with C++03):
sc_signal <T> in0, in1, out; // sc_signal models a “wire”
sc_signal <bool> sel;
void mux() { out = sel ? in0 : in1; } // function that models mux behaviour
SC_METHOD(mux); // Creates a process (registers a function in discrete-event scheduler)
sensitive << in0 << in1 << sel; // sets a “sensitivity list” ( ~ a list of inputs ) for created processAs you may notice this is quite verbose. And error-prone: you can easily forget to specify some input in sensitivity list and have very hard to debug behavior.
So I’m researching if there is a way to invent a better syntax using lambdas and reflection.
As for lambdas I'm not sure yet whether to reflect them like anonymous types with a function call operation or as functions.
--
You received this message because you are subscribed to the Google Groups "SG 7 - Reflection" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reflection+unsubscribe@isocpp.org.
To post to this group, send email to refle...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/reflection/.
For more options, visit https://groups.google.com/a/isocpp.org/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to reflection+...@isocpp.org.
To post to this group, send email to refle...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/reflection/.
For more options, visit https://groups.google.com/a/isocpp.org/d/optout.
---- Matus Chochlik