Core with Reason
Montana opened this issue · 2 comments
Hey all,
This is the command I'm using for compilation: rebuild accum.native.
When I have this in _tags
:
true: package(core,ppx_jane)
true: thread,debug
My error changes (variantly), but I still don't know what the root cause is:
File "_tags", line 1, characters 6-28:
Warning: tag "package" does not expect a parameter but is used with parameter "core,ppx_jane."
File "_tags," line 1, characters 6-28:
Warning: the tag "package(core,ppx_jane)" is not used in any flag or dependency declaration, so that it will have no effect; it may be a typo. Otherwise, you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning.
+ /Users/Montana/.opam/4.02.3/bin/ocamldep.opt -modules -pp refmt -impl accum2.re | tee accum2.re.depends accum2.ml.depends
accum2.re: Core Float In_channel
+ /Users/Montana/.opam/4.02.3/bin/ocamlc.opt -c -g -thread -pp '-g -thread' -pp refmt -o accum2.cmo -intf-suffix .rei -impl accum2.re
File "accum2.re", line 1, characters 5-13:
Error: Unbound module Core
Command exited with code 2.
The compilation was unsuccessful after building two targets (0 cached) at 00:00:00.
The second function, often called the “stub code”, is a simple wrapper around the first function that converts its arguments from OCaml values to C values, call the first function, and convert the returned C value to OCaml value. For instance, here is the stub code for the input primitive:
CAMLprim value input(value channel, value buffer, value offset, value length)
{
return Val_long(getblock((struct channel *) channel,
&Byte(buffer, Long_val(offset)),
Long_val(length)));
}
I've tried mostly all of the allocating blocks in OCaml:
Atom(t)
returns an “atom” (zero-sized block) with tag t. Zero-sized blocks are preallocated outside of the heap. It is incorrect to try and allocate a zero-sized block using the functions below. So for instance, Atom(0) represents the empty array.
caml_alloc(n, t)
returns a fresh block of size n with tag t. If t is less than No_scan_tag,then
the fields of the block are initialized with a valid value in order to satisfy the GC constraints.
caml_alloc_tuple(n)
returns a fresh block of size n words, with tag 0
.
I do understand that after a structured block (a block with tag less than No_scan_tag
) is allocated with the low-level functions, all fields of this block must be filled with well-formed values before the next allocation operation.
I was thinking of coding a wrapper, so let's say if the file's called accum.re
, it can be compiled to a native binary with:
ocamlfind ocamlc -g -thread -package ppx_jane -package core -pp refmt -linkpkg -o accum.native -impl accum.re
I've heard with reasonbuild
it's possible to work around the bug by running reasonbuild
directly:
env OCAMLFIND_COMMANDS="ocamlc=$(which reopt)" reasonbuild -use-ocamlfind accum.native
Still, nothing has worked; I may check DockerHub to see if there are any containers with this. It's hardly the best fix, but a workaround nonetheless.
It also seems like callbacks from C to OCaml do not work. If the C code wishes to catch exceptions escaping the OCaml function, it can use the functions caml_callback_exn, caml_callback2_exn
, caml_callback3_exn
, caml_callbackN_exn.
These functions take the same arguments as their non-_exn
counterparts, but catch escaping exceptions and return them to the C code.
I think I've found the fix for this is, if Is_exception_result returns“true”
, an exception escaped, and its value (the exception descriptor) can be recovered using Extract_exception.
Cheers,
Montana Mendy
This appears to be an AI-generated spam issue. Closing.