Skip to content

Commit

Permalink
Document native/bytecode difference
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Jan 4, 2022
1 parent 1c3a69f commit 6a299aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion toplevel/native/topeval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,15 @@ let execute_phrase print_outcome ppf phr =
let sg' = Typemod.Signature_names.simplify newenv names sg in
ignore (Includemod.signatures oldenv ~mark:Mark_positive sg sg');
Typecore.force_delayed_checks ();
(* The expression is "named" after typing in order to ensure that both
(* `let _ = <expression>` or even just `<expression>` require special
handling in toplevels, or nothing is displayed. In bytecode, the
lambda for <expression> is directly executed and the result _is_ the
value. In native, the lambda for <expression> is compiled and loaded
from a DLL, and the result of loading that DLL is _not_ the value
itself. In native, <expression> must therefore be named so that it can
be looked up after the DLL has been dlopen'd.
The expression is "named" after typing in order to ensure that both
bytecode and native toplevels always type-check _exactly_ the same
expression. Adding the binding at the parsetree level (before typing)
can create observable differences (e.g. in type variable names, see
Expand Down

0 comments on commit 6a299aa

Please sign in to comment.