if I just require a module in the REPL and run a function from it, will the function be JIT compiled?
@andreiformiga yes
@samth thank you, that’s good to know
I think Racket’s REPL is more like a “RECEPL”: Read Expand Compile Eval Loop.
Plus, Compile is really both (a) compile fully-expanded Racket to bytecode and (b) JIT compile bytecode to machine code.
@lexi.lambda That might work, but I think the best approach would be to do something like expand-syntax-top-level-with-compile-time-evals, but using local-expand with a non-empty stop list)to replace expand-syntax-to-top-form, and using a trampoline to replace eval. By “trampoline”, I mean that the macro would return (begin <form-to-eval> (#%top-interaction <rest-to-continue-with>)). That would be similar to the way that internal-definition forms like block work (see racket/block), except that you don’t have the hassle of an explicit definition context at the top level.
@mflatt Hmm, would that work? If I only expand to (begin <form> (#%top-interaction <more>)), won’t the use of #%top-interaction be expanded before <form> is evaluated, ended up at the same place we started?
No, eval splices begin into the top-level sequence, evaluating <form> before continuing the expansion of (#%top-interaction <more>))
I’ve pushed a repair for the other problem, in case that helps with some part of the puzzle
I see, that makes sense. I ended up getting something working using the hack I wrote above, but your solution sounds better. I will try switching to something like what you describe at some point.
Is this a utility that would be useful in syntax/toplevel?
It sounds useful in a library – maybe not in syntax/toplevel, but maybe cross-referenced with it, so that eval-time and expand-time functionality is not unnecessarily bundled together