companion_cube has quit [Ping timeout: 245 seconds]
dedgrant has joined #ocaml
loli has quit [Ping timeout: 246 seconds]
silver has quit [Read error: Connection reset by peer]
loli has joined #ocaml
jbrown has quit [Remote host closed the connection]
iovec has joined #ocaml
loli has quit [Ping timeout: 246 seconds]
loli has joined #ocaml
gravicappa has joined #ocaml
ggole has joined #ocaml
jao has quit [Ping timeout: 246 seconds]
tormen_ has joined #ocaml
amcorvi has quit [Ping timeout: 258 seconds]
tormen has quit [Ping timeout: 258 seconds]
marvin2 has quit [Ping timeout: 258 seconds]
loli has quit [Ping timeout: 245 seconds]
loli has joined #ocaml
govg has quit [Ping timeout: 246 seconds]
JimmyRcom has quit [Ping timeout: 250 seconds]
loli has quit [Ping timeout: 268 seconds]
Birdface has quit [Remote host closed the connection]
Birdface has joined #ocaml
loli has joined #ocaml
hsrt^ has quit []
ocabot has joined #ocaml
companion_cube has joined #ocaml
zmt01 has joined #ocaml
zmt00 has quit [Ping timeout: 250 seconds]
loli has quit [Ping timeout: 268 seconds]
loli has joined #ocaml
ziyourenxiang has quit [Ping timeout: 246 seconds]
dmiles has quit [Read error: Connection reset by peer]
sagotch has joined #ocaml
Jesin has quit [Ping timeout: 257 seconds]
Jesin has joined #ocaml
erwanou_ has quit [Ping timeout: 244 seconds]
err0ne has quit [Ping timeout: 244 seconds]
dmiles has joined #ocaml
erwanou has joined #ocaml
err0ne has joined #ocaml
Serpent7776 has joined #ocaml
loli has quit [Ping timeout: 246 seconds]
sagotch has quit [Quit: Leaving.]
mfp has joined #ocaml
loli has joined #ocaml
bartholin has joined #ocaml
flodin has quit [Remote host closed the connection]
ollehar_ has joined #ocaml
ollehar has joined #ocaml
freyr69 has joined #ocaml
dhil has joined #ocaml
ygrek has joined #ocaml
loli has quit [Ping timeout: 244 seconds]
Haudegen has joined #ocaml
kakadu has joined #ocaml
marvin2 has joined #ocaml
<freyr69>
Is CAMLreturn0 returning unit?
<freyr69>
I have - : unit = <unknown constructor> in utop
<freyr69>
Should I explicitly return unit?
<def`>
|
<def`>
CAMLreturn0 is for void functions.
<freyr69>
Yes
<freyr69>
and what's the signature?
<def`>
void functions cannot be bound to external
<freyr69>
Ah
<def`>
an external should return a value
<def`>
and use CAMLreturn(Val_unit);
<freyr69>
Thanks
<freyr69>
it works
<def`>
CAMLprim value my_function_returning_unit(value x) { CAMLparam1(x); ... CAMLreturn(Val_unit); };
<def`>
np :)
loli has joined #ocaml
<freyr69>
Should I add all input vals to CAMLparam1?
<freyr69>
I see CAMLparam0 in the examples
<def`>
that's the safe approach.
<def`>
Unless you know too much about OCaml internals, always pass every values to CAMLparamn
<def`>
(If you have more than five, you can do CAMLparam5(a,b,c,d,e); CAMLxparam1(f);)
<freyr69>
Even Unit?
<freyr69>
ok
<def`>
Strictly speaking it is not necessary for unit, but because of some implementation details you should not rely on.
<freyr69>
def`: what about CAMLlocal, I shouldn't pass them in CAMLparam to, right. Locally allocated in CAMLlocal, arguments in CAMLparam, is that right?
<def`>
That's right.
<def`>
CAMLparam: register a root
<def`>
CAMLlocal: declare a local and register it as a root
<def`>
so, CAMLlocal already does the job.
<freyr69>
so I could skip CAMLparam?
<def`>
No
<freyr69>
I see, I need both
<def`>
You cannot use CAMLlocal if there is no CAMLparam in scope.
<def`>
If you have no params but need locals, use CAMLparam0; CAMLlocal(...);
<def`>
You might be interested in section 2.3 "Memory management macros"
<freyr69>
Thanks
<freyr69>
Hope one day there will be a high level Ctypes-like ffi in ocaml
asymptotically has joined #ocaml
gareppa has quit [Remote host closed the connection]
<freyr69>
Am I right that there is other way to return result or option type but to guess the value representation (so no polymorphic variants from ffi)?
<def`>
You can do polymorphic variants in FFI but that's tricky
Haudegen has quit [Remote host closed the connection]
<MK__>
So, we have some standard libraries, and then we can use some extended ones in the Core (open Core changes the scope if I'm not wrong). Is that correct?
averell has quit [Quit: .]
<MK__>
scope -> namespace
<companion_cube>
something like that
<companion_cube>
JaneStreet reimplemented their own standard library (named Core) and it's their habit to `open Core` to shadow existing stuff with their alternatives
kakadu_ has quit [Remote host closed the connection]
<MK__>
I can see List.map2_exn in both Basic and Core libraries. Are they different implementations?
<MK__>
Base
<companion_cube>
Base is the trimmed down version of Core
<MK__>
What is the main difference?
averell has joined #ocaml
loli has joined #ocaml
<companion_cube>
it's less big :D
<companion_cube>
(core is r eally big)
Guest20349 has joined #ocaml
Guest20349 has quit [Remote host closed the connection]
Haudegen has joined #ocaml
bartholin has quit [Remote host closed the connection]
<MK__>
:D
asymptotically has quit [Quit: Leaving]
MK__ has quit [Ping timeout: 256 seconds]
Haudegen has quit [Read error: Connection reset by peer]