I thought about what it would take to allow this in LFortran.
Currently, all compile time evaluation is done in AST->ASR in LFortran. To evaluate things like sin, it is simply implemented in the compiler itself, independent of any runtime implementation. If we allow to execute any pure or simple function at compile time, then one would call the pure function via LLVM at compile time.
There is a security implication of calling a possibly untrusted code at compile time. But otherwise I think it is technically doable. But I would feel safer to prototype this first, to make sure.
I know Zig has comptime: What is Zig's Comptime? | Loris Cro's Personal Blog and I thought the compiler has a separate interpretation phase where it can interpret Zig’s code — but maybe I misunderstood. Either way, I want to avoid having to implement an interpreter, that feels like a lot of duplication. Fortunately it seems it should be possible to just call the already compiled function.