STR-346: Calling strategies by their name
Sometimes it is useful to be able to call a strategy based on its name (as in a string).
An example is the dr-undefine-rules(|Rs,scope,dep) strategy which calls for each R in Rs (a list of strings) the rule undefine-R(|scope,dep). The Rs involved are unknown at the time of definition of dr-undefine-rules.
Plan: add a primitive call(t|s1,…,sn|t1,…,tm) which evaluates the term t, uses the resulting string str and arities to do a lookup in a table, which returns a pointer to the function f implementing the strategy named str_n_m, and calls str_n_m(s1,…,sn,t1,…,tm,cur) with cur the current term.
This requires:
at start-up time create a table mapping strategy names to function pointers
declaring which strategies can be called in this way
implementing the fucntion in C
Advantages
Submitted on 21 July 2005 at 14:39
- makes linking libraries into the interpreter trivial
Issue Log
STR-346, visser:
The `call from name’ feature is a more general solution to this problem.
STR-346, anya:
A version which simply calls a function through a pointer stored in an ATerm would also be useful (and a bit unsafe…).
STR-346, visser:
Is required for M2
STR-346, visser:
This isssue is (temporarily) solved by the DYNAMIC-CALLS hack from issue STR-346. A cleaner solution should be designed eventually. Therefore, leaving this issue open (but moving it to a future release).
Log in to post comments