Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.13.0 released: https://ocaml.org/releases/4.13.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
_whitelogger has joined #ocaml
<d_bot> <Wulfman> Is there someone that know `core.command` and ocmal `exception` i don't understand with `try command.run mycommand with My_Exception -> 1` return `uncaught exception My_Exception` .?...
<d_bot> <Wulfman> Why isn't the try catch block catching it ?
<d_bot> <NULL> When an error reaches toplevel, `Exception: My_exception` is printed. If it's not the message you get, it indicates that something (like `command.run`) catches all exceptions and exits early. If it is indeed the case, you want to put your try/except inside the argument of `command.run`
<d_bot> <NULL> (I don't know `core.command` though, I can't help more about that)
brettgilio has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
waleee has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
perrierjouet has quit [Quit: WeeChat 3.3]
<d_bot> <leviroth> I agree, I think the thought is that you put all of your program logic, including exception handling, inside the command
perrierjouet has joined #ocaml
perrierjouet has quit [Quit: WeeChat 3.3]
<d_bot> <leviroth> Oddly this one-line program prints the uncaught exception differently than it does if I remove the `let _ignoreme` bit: `let () = let _ignoreme = Core.sec in raise (Invalid_argument "foo")`
<d_bot> <leviroth> It seems to do this if I reference anything in `Core` that isn't just re-exported from `Core_kernel`, so I assume it has something to do with how dune decides to link things.
spip has joined #ocaml
spip is now known as Guest2664
Guest456 has quit [Ping timeout: 256 seconds]
mbuf has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slothby has joined #ocaml
rgrinberg has joined #ocaml
Haudegen has joined #ocaml
vicfred has joined #ocaml
ansiwen has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
gravicappa has joined #ocaml
shawnw has joined #ocaml
Serpent7776 has joined #ocaml
perrierjouet has joined #ocaml
jlrnick has joined #ocaml
olle has joined #ocaml
dwt_ has quit [Quit: ZNC 1.8.2 - https://znc.in]
dwt_ has joined #ocaml
waleee has joined #ocaml
lobo has quit [Quit: lobo]
lobo has joined #ocaml
kakadu has quit [Ping timeout: 256 seconds]
kakadu has joined #ocaml
<hackinghorn> hi, any guide on using In_channel, Out_channel?
<d_bot> <darrenldl> is bindlib the goto these days?
<d_bot> <darrenldl> hackinghorn: what specific things you're trying to do?
<hackinghorn> I just want to write to a file using Out_channel
<hackinghorn> looks like there is nothing much on Out_channel with capital O
<rgrinberg> hackinghorn Out_channel.write_all?
jlrnick has quit [Ping timeout: 240 seconds]
<hackinghorn> I don't know, I guess. Maybe I can try that, I guess
<hackinghorn> do I have to open or close or anything?
<hackinghorn> a line of explanation would be good
<hackinghorn> okay I guess I can try that
<rgrinberg> Here's an example: Out_channel.write_all "test" ~data:"foo bar baz"
<rgrinberg> closing and opening is done for you by this function
<hackinghorn> aight, thanks, that looks simple
<d_bot> <let Butanium = raise Not_found;;> ```ocaml
<d_bot> <let Butanium = raise Not_found;;> let log_datas ?(close=true) f file (datas: 'a list) =
<d_bot> <let Butanium = raise Not_found;;> let oc = get_oc file in
<d_bot> <let Butanium = raise Not_found;;> List.iter (fun x -> Printf.fprintf oc "%s" @@ f x) datas;
<d_bot> <let Butanium = raise Not_found;;> if close then close_out oc; oc
<d_bot> <let Butanium = raise Not_found;;> ```
<d_bot> <let Butanium = raise Not_found;;> with
<d_bot> <let Butanium = raise Not_found;;> ```ocaml
<d_bot> <let Butanium = raise Not_found;;> let get_oc file = open_out @@ file.file_path ^ file.file_name
<d_bot> <let Butanium = raise Not_found;;> ```
<d_bot> <let Butanium = raise Not_found;;> this prints datas from a list in a file
<d_bot> <let Butanium = raise Not_found;;> full module here if you want to give it a look https://github.com/Butanium/monte-carlo-tree-search-TSP/blob/master/tools/File_log.ml
tomku has quit [Read error: Connection reset by peer]
<hackinghorn> write_all shows me "No such file or directory"
<d_bot> <Wulfman> @NULL @therewolf Thanks :). I do observe the same odd behavior from the command line with the message changing from `Fatal Error : exception exn` to `Uncaught exception : exn` . When you say "catches all exceptions and exits early", what mechanism are you thinking for exiting ? doesn't running `exit` throw and exception ? can we "catch" the effect of exit ?
<hackinghorn> maybe i need to create directory
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wingsorc__ has joined #ocaml
wingsorc has quit [Ping timeout: 252 seconds]
tomku has joined #ocaml
leah2 has quit [Quit: trotz alledem!]
leah2 has joined #ocaml
bartholin has joined #ocaml
olle_ has joined #ocaml
shawnw has quit [Ping timeout: 256 seconds]
shawnw has joined #ocaml
<d_bot> <Wulfman> Ho... I think core.command open a separate thread of something like that. The stack trace is really short and doesn't start from my entry-point
Guest6030 has quit [Quit: WeeChat 3.3]
unyu has joined #ocaml
perrierjouet has quit [Quit: WeeChat 3.3]
perrierjouet has joined #ocaml
rks` has quit [Ping timeout: 240 seconds]
asm has joined #ocaml
asm has quit [Changing host]
<d_bot> <leviroth> @Wulfman I don't think `exit` raises an exception. I think it calls the unix `exit` function, ending the process directly.
terrorjack has joined #ocaml
kakadu has quit [Ping timeout: 240 seconds]
kakadu has joined #ocaml
jlrnick has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
rks` has joined #ocaml
shawnw has quit [Ping timeout: 256 seconds]
jlrnick has quit [Ping timeout: 240 seconds]
vicfred has quit [Quit: Leaving]
gravicappa has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
spip has joined #ocaml
Guest2664 has quit [Ping timeout: 268 seconds]
spip is now known as Guest7956
zebrag has joined #ocaml
waleee has quit [Quit: WeeChat 3.3]
<d_bot> <antron> how is the performance of mutable fields affected by multicore?
<sadiq> there should be no difference?
<sadiq> apart from maybe some cache effects with remember sets and different threads
<companion_cube> the write barrier didn't change at all?
<sadiq> so the more nuanced answer is that yes but not on x86
<companion_cube> good, good
<sadiq> there's maybe a tiny difference in marking behaviour
<sadiq> antron: have you found one?
<d_bot> <antron> no, i haven't found a difference. but i'm considering using some relatively short-lived records with mutable fields, and worried if that will be a problem in multicore
<sadiq> on x86 you shouldn't see anything
<d_bot> <antron> ok, good. what about other architectures?
<sadiq> on arm64 the memory model could have a small impact
<sadiq> (though again, would be surprised if you could see it)
rwmjones is now known as rwmjones|HOLS
<d_bot> <antron> is it something like on the scale of the cost of a few extra arithmetic instructions or so?
<sadiq> https://kcsrk.info/papers/pldi18-memory.pdf has it overall at 0.6% but doesn't break out the stores
<sadiq> also the ThunderX was a funky chip, I suspect the difference will be even smaller on something like the M1
<sadiq> antron: it's the memory barrier
<sadiq> x86 is always acquire-release and on the M1 (and the modern ARM cores) it's also pretty well optimised
<sadiq> for the M1 especially so because of x86 emulation
gravicappa has joined #ocaml
<d_bot> <antron> thank you
<sadiq> no problem
waleee has joined #ocaml
rak has quit [Quit: Segmentation fault (core recycled)]
rak has joined #ocaml
bartholin has quit [Quit: Leaving]
jlrnick has joined #ocaml
mbuf has quit [Quit: Leaving]
rgrinberg has joined #ocaml
jlrnick has quit [Ping timeout: 268 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Anarchos has joined #ocaml
gravicappa has quit [Ping timeout: 240 seconds]
olle_ has quit [Ping timeout: 240 seconds]
rgrinberg has joined #ocaml
Everything has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
chrisz has quit [Quit: leaving]
<rgrinberg> hackinghorn indeed you need to create the dir first
<d_bot> <Kakadu> Could you recommend some reading (except reading C) about closure representation when flambda is enabled?
<companion_cube> afaik closure representation is the same
<companion_cube> there's just fewer closures :p
Anarchos has joined #ocaml
<d_bot> <Kakadu> I tried to print them from C and it looks like they are not the same
<d_bot> <Kakadu> or maybe I'm wrong....
<d_bot> <RegularSpatula> They’re basically an alternative interface to the normal in and out channels…the mli docs are decent for these. Did you still need a couple more examples ?
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Everything has quit [Quit: leaving]
cedric has joined #ocaml
Serpent7776 has quit [Quit: leaving]
chrisz has joined #ocaml
waleee has quit [Ping timeout: 268 seconds]
<zozozo> kakadu: the representation of closures is the same, but flambda might generate different sets of closures than closure
Tuplanolla has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<d_bot> <Kakadu> It looks like there is a difference but I don't yet fully understand where it is. (See README https://github.com/kakadu/asdf)
* d_bot <Kakadu> will investigate it later
<d_bot> <Kakadu> if somebody has any text description about flambda and partial applications of closures, it will be appreciated.
cedric has quit [Quit: Konversation terminated!]
kakadu has quit [Remote host closed the connection]
kakadu has joined #ocaml
<zozozo> kakadu: okay, so the results you get are perfectly fine as far as I can tell
<zozozo> the main difference is that flambda is able to see that the "free variables" of your closures are actually compile-time constants, so there is no need for the closures to contain these, since they are known at compile-time, and can simply be substituted in the code
<zozozo> the overall way closures are represented is the same, but flambda can optimize the code so that it generates different, smaller closures (e.g. with some free variables removed)
<zozozo> kakadu: also, note that the "closure with X free variables" output of your examples is completely wrong
<zozozo> I'll try and do a small writeup tomorrow about closure representation (it's the second time the topic has come up on irc, maybe it's time to have a doc to point people to, ^^)