andreiformiga
2017-8-10 21:07:46

if I just require a module in the REPL and run a function from it, will the function be JIT compiled?


samth
2017-8-10 21:09:49

@andreiformiga yes


andreiformiga
2017-8-10 21:10:19

@samth thank you, that’s good to know


greg
2017-8-10 23:56:08

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.


mflatt
2017-8-11 00:25:48

@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.


lexi.lambda
2017-8-11 00:33:44

@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?


mflatt
2017-8-11 00:34:53

No, eval splices begin into the top-level sequence, evaluating <form> before continuing the expansion of (#%top-interaction <more>))


mflatt
2017-8-11 00:35:58

I’ve pushed a repair for the other problem, in case that helps with some part of the puzzle


lexi.lambda
2017-8-11 00:37:07

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.


lexi.lambda
2017-8-11 00:37:46

Is this a utility that would be useful in syntax/toplevel?


mflatt
2017-8-11 01:07:22

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