bartholin has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
pukkamustard has quit [Excess Flood]
pukkamustard has joined #ocaml
humasect has joined #ocaml
wingsorc has quit [Ping timeout: 240 seconds]
humasect has quit [Quit: Leaving...]
lobo[m] has quit [Read error: Connection reset by peer]
zebrag[m] has quit [Write error: Connection reset by peer]
mclovin has quit [Write error: Connection reset by peer]
jmcantrell has quit [Write error: Connection reset by peer]
reynir[m] has quit [Read error: Connection reset by peer]
spip has joined #ocaml
mclovin has joined #ocaml
lobo[m] has joined #ocaml
reynir[m] has joined #ocaml
zebrag[m] has joined #ocaml
jmcantrell has joined #ocaml
zebrag[m] has quit [Ping timeout: 240 seconds]
mclovin has quit [Ping timeout: 240 seconds]
reynir[m] has quit [Ping timeout: 260 seconds]
jmcantrell has quit [Ping timeout: 260 seconds]
lobo[m] has quit [Ping timeout: 252 seconds]
zebrag[m] has joined #ocaml
mclovin has joined #ocaml
reynir[m] has joined #ocaml
lobo[m] has joined #ocaml
jmcantrell has joined #ocaml
reynir[m] has quit [Remote host closed the connection]
mclovin has quit [Remote host closed the connection]
lobo[m] has quit [Remote host closed the connection]
jmcantrell has quit [Read error: Connection reset by peer]
zebrag[m] has quit [Remote host closed the connection]
mclovin has joined #ocaml
lobo[m] has joined #ocaml
reynir[m] has joined #ocaml
jmcantrell has joined #ocaml
zebrag[m] has joined #ocaml
azimut has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
neiluj has joined #ocaml
<neiluj>
hi!
<neiluj>
are optional default values evaluated if a value is supplied?
<neiluj>
for instance `let foo ?(x=bar()) () = x`
<theblatte>
I'd say yes but that's easy to test :)
<theblatte>
also I'd be wrong
<discocaml>
<dumbpotato> ```# let counter = ref 0
<discocaml>
<dumbpotato> let increment refcell =
<discocaml>
<dumbpotato> let current = !refcell in
<discocaml>
<dumbpotato> refcell := current + 1;
<discocaml>
<dumbpotato> current
<discocaml>
<dumbpotato> let add ?(x=(increment counter)) y = x + y;;
<discocaml>
<dumbpotato> # add 0;;
<discocaml>
<dumbpotato> - : int = 0
<discocaml>
<dumbpotato> # add 1;;
<discocaml>
<dumbpotato> - : int = 1
<discocaml>
<dumbpotato> ```
<discocaml>
<dumbpotato> looks like it’s evaluated every time like in javascript not once like in python
<neiluj>
thanks, indeed ocaml is strict
<companion_cube>
(it's the good choice, too; python's choice is broken and a classic footgun)
<neiluj>
actually, no: if a value is provided the default value is not executed
<neiluj>
let f ?(x = assert false) () = x;;
<neiluj>
neither f ~x:3;; nor f ~x:3 ();; crash
Haudegen has joined #ocaml
neiluj has quit [Quit: WeeChat 3.7.1]
Serpent7776 has quit [Quit: WeeChat 1.9.1]
<discocaml>
<leviroth> Weirdly the behavior of default arguments doesn’t appear to be described at all in the language reference chapter of the manual
<companion_cube>
surprising indeed, I don't find anything either
Haudegen has quit [Quit: Bin weg.]
<discocaml>
<octachron> The behavior is partially unspecified currently (because it matters for optimizing heavy user of optional arguments like lablgtk), see https://github.com/ocaml/ocaml/pull/10653 .
<discocaml>
<leviroth> I am also kind of ambivalent about the behavior. I mean it’s called a default value, but the semantics are that it’s a default *expression* that gets evaluated later on!
<companion_cube>
that's fair, but it being an expression is the correct behavior when you think of it
bartholin has joined #ocaml
mbuf has quit [Quit: Leaving]
motherfsck has joined #ocaml
<adrien>
how much more memory-expensive is Foo (1,2,3) compared to (1,2,3)?
<companion_cube>
if declared as `… | Foo of int * int * int`, same amount of memory
<adrien>
thanks; and, how could they be declared otherwise?
<adrien>
s/they/it/
<companion_cube>
`| Foo of (int * int * int)`
<octachron>
"Foo of (int * int * int)" is a block of size 1 containing a pointer to the triple.
<companion_cube>
which is 2 words more
<adrien>
ah, ok; makes sense, thanks
* adrien
is trying to get his program to use less than 16GB memory
<companion_cube>
have you tried statmemprof?
<adrien>
no, not at the moment
<adrien>
I've been mostly reading the code because it's short and I think I actually found the right place to insert Gc.do_something ()
<adrien>
basically, after "BatIMap.(imap |> from low |> until high)" where low and high are close relative to the bounds of imap
<adrien>
and actually I've also wrapped that in a function because I don't know if this form makes the intermediate value (between from and until) collectable
<adrien>
I can't really tell if it works or if it makes the program so slow that the memory seems to not increase
Wojciech_K has joined #ocaml
wingsorc has joined #ocaml
<adrien>
I let the machine do the work; basically that part of the code really seems to need 14GB or so; another later part generates more garbage and more frequent collections help stay under 16GB instead of reaching 21GB at the cost of CPU time; next step will be to analyse the large value but it's an interval map for [0..200M] with more than 10M values and it's possible memory usage cannot be improved