“Eval” a string in OCaml

前端 未结 2 536
粉色の甜心
粉色の甜心 2021-02-09 20:44

I\'m trying to \"eval\" a string representing an OCaml expression in OCaml. I\'m looking to do something equivalent to Python\'s eval.

So far I\'ve not been able to find

2条回答
  •  猫巷女王i
    2021-02-09 21:12

    OCaml is a compiled (not interpreted) language. So there's no simple way to do this. Certainly there are no language features that support it (as there are in almost every interpreted language). About the best you could do would be to link your program against the OCaml toplevel (which is an OCaml interpreter).

提交回复
热议问题