News for hackers. Stuff that matters.
Re:Neat Rust Tricks: Passing Closures to C by comex on Monday November 25, 2019 @10:10PM (#21635357)
Generating native function pointers on the fly:

- is inherently slow, because CPUs have separate data and instruction caches;

- is extra slow in practice because you need a separate allocation for executable memory (unless your stacks and heap are RWX, which is a terrible idea);

- is not portable, requiring architecture- and OS-specific code; and

- is not supported at all in many environments (of varying levels of braindeadness).

For a statically compiled language like Rust, it makes much more sense to use the context pointer.

There are no comments on this comment yet.