Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow let@ to be inlined #183

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/picos_structured/finally.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let[@inline] finally release acquire = (release, acquire)
[release]. Allocations here would mean that e.g. pressing Ctrl-C, i.e.
[SIGINT], at the right moment could mean that [release] would not be called
after [acquire]. *)
let[@inline never] ( let@ ) (release, acquire) body =
let[@inline never] let_at acquire body release =
let x = acquire () in
match body x with
| y ->
Expand All @@ -19,6 +19,8 @@ let[@inline never] ( let@ ) (release, acquire) body =
release x;
raise exn

let[@inline] ( let@ ) (release, acquire) body = let_at acquire body release

type ('a, _) tdt =
| Nothing : ('a, [> `Nothing ]) tdt
| Resource : {
Expand Down Expand Up @@ -55,7 +57,7 @@ let ( let^ ) (release, acquire) body =
end
end
in
( let@ ) (release, acquire) body
let_at acquire body release

let[@inline never] check_no_resource () =
(* In case of cancelation this is not considered an error as the resource was
Expand Down
Loading