|Pliant talk forum
Feature request: meta apply
An "apply" meta would be useful, which takes a Function as its
first argument, followed by a list of types and values to pass
as arguments. It would type check the arguments, perform any
casts if necessary, execute the function, and return the result.
|Message posted by maybe Michael FIG on 2006/05/05 03:25:49
|Does anybody have suggestions on how to write this kind of meta? Or just
have some code that I could borrow?
Initially, I would just cheat, and do something like:
var Link:Expression app :> new Expression
app add (instruction f (argument ...)...)
but ideally the meta would not depend on "execute", rather would
generate a platform-specific executable and call it directly.
This is needed to resolve a bootstrapping issue, since the Pliant
compiler depends on using C function pointers directly, and I don't
know how to do that from within Pliant.
An example is in /pliant/language/compiler/expression/expression.c, in
struct Function *f; [...]
I don't know how to do that in Pliant without invoking "execute".
|Message posted by hubert.tonneau on 2006/05/05 08:56:48
You first declare an indirect function:
function prototype rewrite_prototype e fun
arg_rw Expression e ; arg Function fun
Then you call it:
rewrite_prototype e f
|Message posted by maybe Michael FIG on 2006/05/11 02:40:38