Stream: t-compiler

Topic: REPL: closure vs locals


oli (Nov 29 2019 at 15:55, on Zulip):

oli yes, that would be acceptable, I think, but would involve some more manipulation of the AST which seemed unnecessary. (that is, this seemed the simpler solution, at no noteworthy performance hit.)

the advantage of the local variable is (I believe) that you can get rid of the closure entirely, and reuse https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.entry_fn

Alexander Regueiro (Nov 29 2019 at 16:14, on Zulip):

that's true, I think, but beyond the above benefit, the closure serves as a nice compartmentalisation of the "user fn", since there would be statements after it in main in any case (and in the future, possibly even before)

oli (Nov 29 2019 at 16:18, on Zulip):

oh, diagnostics again, right

oli (Nov 29 2019 at 16:18, on Zulip):

otherwise you may get errors/warnings about things you didn't write

Alexander Regueiro (Nov 29 2019 at 16:21, on Zulip):

yup

Alexander Regueiro (Nov 29 2019 at 16:24, on Zulip):

but the other point I was thinking of: with the closure, it's very straightforward for the miri evaluator to detect when the "user fn" is done with, and the locals' memory can be saved (and not any other locals in main, which shouldn't be saved).

oli (Nov 29 2019 at 16:26, on Zulip):

right

Alexander Regueiro (Nov 29 2019 at 16:29, on Zulip):

cool, glad this is clear now.

oli (Nov 29 2019 at 16:30, on Zulip):

Thanks for explaining it

Alexander Regueiro (Nov 29 2019 at 16:32, on Zulip):

no problem.

Last update: Dec 12 2019 at 00:45UTC