Conversation
lpw25
left a comment
There was a problem hiding this comment.
A few changes needed but mostly looks good.
fa20d57 to
2411722
Compare
|
This PR has been rebased on top of version 4.14. |
|
The commit 5bb4963 (after discussion with @lpw25 who discussed with @stedolan ) made it so that any function ending with |
typing/untypeast.ml
Outdated
| | Texp_unregion exp -> | ||
| Pexp_apply ({ | ||
| pexp_desc = | ||
| Pexp_extension | ||
| ({ txt = "ocaml.unregion"; loc} | ||
| , PStr []); | ||
| pexp_loc = loc; | ||
| pexp_loc_stack = []; | ||
| pexp_attributes = []; | ||
| }, [Nolabel, sub.expr sub exp]) |
There was a problem hiding this comment.
I recall that this file is mostly deprecated, but I wrote what I think is right anyway.
typing/typecore.ml
Outdated
| | Pexp_apply | ||
| ({ pexp_desc = Pexp_extension({ | ||
| txt = "extension.unregion" | "ocaml.unregion" | "unregion" as txt}, PStr []) }, | ||
| [Nolabel, sbody]) -> | ||
| if (txt == "extension.unregion") && not (Clflags.Extension.is_enabled Local) then | ||
| raise (Typetexp.Error (loc, Env.empty, Local_not_enabled)); |
There was a problem hiding this comment.
I'm merging the two very similar pattern-matching cases, and testing for one of them in the body. This might not be a good coding style, but the alternative is to have an auxiliary function that has too many arguments.
typing/rec_check.ml
Outdated
| | Texp_unregion e -> | ||
| classify_expression env e |
There was a problem hiding this comment.
Please confirm this is correct
typing/rec_check.ml
Outdated
| | Texp_probe {handler} -> | ||
| expression handler << Dereference | ||
| | Texp_probe_is_enabled _ -> empty | ||
| | Texp_unregion e -> expression e |
There was a problem hiding this comment.
please confirm this is correct
typing/tast_iterator.ml
Outdated
| sub.expr sub e | ||
| | Texp_probe {handler;_} -> sub.expr sub handler | ||
| | Texp_probe_is_enabled _ -> () | ||
| | Texp_unregion exp -> sub.expr sub exp |
There was a problem hiding this comment.
Please confirm this is correct
typing/tast_mapper.ml
Outdated
| | Texp_unregion exp -> | ||
| Texp_unregion (sub.expr sub exp) |
There was a problem hiding this comment.
Please confirm this is correct
typing/typecore.ml
Outdated
| | Texp_letop _ | ||
| | Texp_extension_constructor _ -> | ||
| false | ||
| | Texp_unregion e -> is_nonexpansive e |
There was a problem hiding this comment.
Please confirm this is correct
typing/typecore.ml
Outdated
| | Texp_unregion e -> | ||
| check e |
There was a problem hiding this comment.
please confirm this is correct
|
We should strongly consider switching to using |
|
Yes -- let's use attributes for anything that can safely be just ignored in the upstream compiler. |
79e7e52 to
5f8ca38
Compare
|
Hmm do you think I should make the change in this PR, or do it some time later? @antalsz @goldfirere |
|
Antal may see things differently, but I think it's best to merge patches when they're not going to cause trouble for others. I think the infrastructure to handle e.g. |
|
Because we can handle |
|
I suggest that this PR to be reviewed as it is, without migrating to the new extension syntax framework, because currently the whole Sometime in the future we should migrate the whole |
typing/typecore.ml
Outdated
| (* CR zqian: this is suspicious, | ||
| because vmode is not the mode of the region; | ||
| ideally the `position` should contain the mode | ||
| of the region so we can pass it to mode_return; | ||
| but this might be fine because of mode-crossing? *) | ||
| mode_return vmode |
There was a problem hiding this comment.
This one needs some inspection.
|
This PR relies on oxcaml/oxcaml#1131 to be merged safely. |
lpw25
left a comment
There was a problem hiding this comment.
Looks pretty good. Should be good to go once various superficial things are fixed.
lpw25
left a comment
There was a problem hiding this comment.
Small small suggestions then this is good to go
This patch adds the support for the
[%exclave]extension, which can be applied to an expression and results in early ending of the current region before the expression is evaluated. As such, it can only appear in the tail position of the region. A motivating example is as follows:where
foois supposed to be some helper function that takes arguments from parent region and returns values also in parent region. The intermediate results (y) it uses are stored in its local stack and released upon entering[%exclave]. As a result, you are not allowed to refer toyin[%exclave].