<discocaml>
<lukstafi> In `f x = g x in f a` can `a` be garbage collected before `g` returns? Imagining `a` is passed through a register that is then reused, so becomes unreachable before `g` returns.
<rustyne>
lukstafi: I’d think so too
<discocaml>
<otini_> I’m not sure to understand the code
<discocaml>
<otini_> do you mean `let f x = g x in f a`?
<discocaml>
<otini_> values that are referred to by local variables of a function are not collected before the function returns
<discocaml>
<otini_> if the GC runs during the execution of `g`, one of the first things it will do will be marking the local roots as live—including the argument of `g`, `x`, which is the same as `a`
zor has joined #ocaml
<discocaml>
<otini_> the way registers or stack slots are allocated is handled transparently
<discocaml>
<otini_> the compiler has generated information about f’s argument list and stack frame size in a table that the GC uses
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 276 seconds]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
<discocaml>
<lukstafi> So `Sys.opaque_identity` might be needed for local bindings, but never for function parameters?
<discocaml>
<lukstafi> i.e. is `let f x = g x; ignore (Sys.opaque_identity x) in f a` meaningless -- equivalent to the original?
pi3ce has quit [Ping timeout: 252 seconds]
pi3ce has joined #ocaml
olle has left #ocaml [#ocaml]
<discocaml>
<otini_> I don’t think there’s any impact of `Sys.opaque_identity` on garbage collection 🤔
<discocaml>
<otini_> You are guaranteed that a value is not collected while it is used
<discocaml>
<octachron> There are some impact of `Sys.opaque_identity` on liveness because it can disallow optimisations that would remove unused variables.
Haudegen has quit [Quit: Bin weg.]
<discocaml>
<octachron> But I mostly see this matters with FFI (when using finalizers to keep alive OCaml-side values owned by a C-side value)
Haudegen has joined #ocaml
tremon has joined #ocaml
<discocaml>
<deepspacejohn> If I have a "fooable" module type, e.g. `module type fooable = sig type t val foo : t -> foo end`, and I want to have versions of it for type constructors with different arities. Is there any better pattern than just defining a type for every arity like `module type fooable1 = sig type 'a t val 'a foo : ('a -> foo) -> 'a t -> foo end`, `module type fooable2 = sig type ('a, 'b) t ....` etc?
zor has quit [Ping timeout: 265 seconds]
dhil has joined #ocaml
euphores has quit [Quit: Leaving.]
euphores has joined #ocaml
<discocaml>
<lukstafi> `g` is a FFI call. I think in one case I'm concerned with the call should not release the OCaml lock. But also asking for the case where the `g` call releases the OCaml lock.
<discocaml>
<deepspacejohn> @otini_ thanks, that's what I figured. I don't want to do anything too clever but just wanted to make sure I wasn't missing something obvious.
<discocaml>
<otini_> If an FFI call doesn’t explicitly release the domain lock, the GC won’t move or collect anything under its feet. If it releases the domain lock, then yes, it should abstain from accessing any OCaml data
<discocaml>
<otini_> (until the lock is re-acquired)
<discocaml>
<lukstafi> Right, because the data can be moved. But I think I only rely on the OCaml data not getting released. The OCaml callback from the C side re-acquires the lock.
<discocaml>
<otini_> if the C function declares its parameters and locals properly, they should not be released.
<discocaml>
<lukstafi> It's all handled by Ctypes.Foreign, so I'd assume so.
<discocaml>
<otini_> I’d assume so too
Serpent7776 has quit [Ping timeout: 260 seconds]
zor has joined #ocaml
dhil has quit [Ping timeout: 248 seconds]
itszor has joined #ocaml
zor has quit [Ping timeout: 265 seconds]
<discocaml>
<gabyfle> Hey 🙂 By any chances, does anyone knows if it's possible to force the github action setup ocaml not to use cygwin but rather msys2 ?