Hacker News new | ask | show | jobs
by jancsika 33 days ago
So for interpreted languages with types that are written in C, how is the engine supposed to tell C it already checked all the arg types manually in the interpreter? In other words: it's safe to go ahead and dereference this function and invoke it with these args.

Seems like C technically requires function declarations for every possible signature. That quickly explodes into hundreds or thousands of function declarations in the header and switch statement.

Edit: clarification

2 comments

I’ve thought about how to let folks prove to Fil-C that Fil-C’s checks are obviated by some higher level checks.

It’s a super hard problem! I don’t have a good answer, but I also can’t prove that it’s impossible

Something something compile Fil-C to WASM64?
I don’t see how that would help
I guess it is the imaginary security that WebAssembly advocates tend to sell, without telling the part that linear memory segments don't have bounds checking within their internals.
If you have an interpreted language, you don't have a C function corresponding to each language function. You have a C interpreter loop with a "current instruction" pointer. When the current interpreted instruction is a call, you check all the things you need to check, push the current IP to a stack, and set the IP to the first instruction of the function.

C's type checker never sees the interpreted language's functions.