<discocaml>
<sotesukeyamaha> I learned it this semester and I had a blast. For me, what's really fun about programming in OCaml is the language is a lot closer to how I think about problems. In particular, a lot of structures are easily solved with recursion but in other languages it's not as natural. It can be a pain to debug but never had this issue so far in OCaml. Most of the time, the things I write give the intended result on the first try. I also love how ex
<discocaml>
<sotesukeyamaha> I learned it this semester and I had a blast. For me, what's really fun about programming in OCaml is the language is a lot closer to how I think about problems. In particular, a lot of problems with data structures are easily solved with recursion but in other languages it's not as natural. It can be a pain to debug but never had this issue so far in OCaml. Most of the time, the things I write give the intended result on the first try.
infinity0 has joined #ocaml
infinity0 has quit [Ping timeout: 252 seconds]
Haudegen has quit [Quit: Bin weg.]
<discocaml>
<dubious245> First time using it this semester and its been a joy so far.
LainIwakura has quit [Ping timeout: 240 seconds]
LainIwakura has joined #ocaml
LainIwakura has quit [Ping timeout: 240 seconds]
agentcasey_ has quit [Quit: ZNC 1.10.x-git-82-9ab81d1d - https://znc.in]
agentcasey has joined #ocaml
amirouche has quit [Quit: WeeChat 4.1.1]
euphores has quit [Quit: Leaving.]
bartholin has joined #ocaml
euphores has joined #ocaml
Tuplanolla has joined #ocaml
amirouche has joined #ocaml
Serpent7776 has joined #ocaml
YuGiOhJCJ has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
switchy has quit [Ping timeout: 244 seconds]
switchy has joined #ocaml
Haudegen has joined #ocaml
zor has joined #ocaml
_jbrown_ has quit [Ping timeout: 276 seconds]
<discocaml>
<froyo> I have a bunch of effectful computations scattered across an executable's main module, with a bunch of definitions relying on effects executing before them
<discocaml>
<froyo> It's basically quite imperative and fiddly but that's fine because it's just the executable
<discocaml>
<froyo> Many parts of the code raise a custom exception which I want to catch globally and give the user die-style error messages that way
<discocaml>
<froyo> Now I could put everything behind functions and pass around values instead of mutating globals etc etc so that I can collect everything in the last part of the module and wrap it in a try block, or I could, instead of raising an exception, just print and call exit, but I wanted to try Printexc.set_uncaught_exception_handler because why not
<discocaml>
<froyo> I match on my exception and print its content, followed by a flush as the docs suggest, and on any other exception I call default_uncaught_exception_handler
<discocaml>
<froyo> the handler doesn't seem to trigger. does it not trigger when the exception is raised with `raise_notrace`?
<discocaml>
<froyo> nvm it doesn't seem to trigger either way
<discocaml>
<froyo> here's a reproduction. I think I just don't understand how to use this function. https://tio.run/##ZY@xEoIwEER7vmKHSgv9AQc7e/8gE8lBMoaEyV1GCv8dA4KN7d7bvd3Y6sHPM00tjeJiwC2lmBA7sCQX@sqTgFaN0SBpx4TDF@LjelVoKuBeaCkxZyZRObQ691bUL1dZHYynhAf1LqDLATThIThdixkYtLR2kV5O7Kq8typcEIxLuqIS4QKBL@h8Zls6mphlw9U/WBvqdPaC/bszT0RvEJfZdTEWch@xzayFWOp5/gA
Serpent7776 has quit [Ping timeout: 252 seconds]
<discocaml>
<octachron> The function doesn't work in REPLs, because REPL needs to handle uncaught exceptions by themselves.
<discocaml>
<octachron> Outside of REPLs, your example works fine.
<discocaml>
<froyo> calling ocaml on a file.ml still goes through the repl's handlers? I was under the impression it sets those up only when we're interactive.
<discocaml>
<octachron> Note also that if you just want error messages, you can use the `register_printer` function
<discocaml>
<octachron> `ocaml script.ml` execute the script in the REPL environment.
<discocaml>
<froyo> yeah but register_printer still prints `Exception:` before calling the custom printer
<discocaml>
<froyo> in any case, thanks octachron that's what I needed to know
Serpent7776 has joined #ocaml
Serpent7776 has quit [Ping timeout: 276 seconds]
chiselfuse has quit [Ping timeout: 264 seconds]
alexherbo2 has joined #ocaml
cawfee has quit [Quit: WeeChat 4.6.1]
cawfee has joined #ocaml
jutty has quit [Quit: jutty]
jutty has joined #ocaml
<discocaml>
<gabyfle> Hi, let say I have a bigarray allocated like this:
<discocaml>
<gabyfle> is there a way for me to tell OCaml to resize the bigarray into something smaller afterwards ? something that would no necessite a full allocation of a smaller bigarray
<discocaml>
<gabyfle> I'm wondering what happens if I just change the dims using `Caml_ba_array_val(bigarray)->dims[i] = something_smaller`, is this "legal" ?
<discocaml>
<gabyfle> to be clear, I build a bigarray with a shape of `(channels, samples)`, but for some formats (like MP3 for example) I might end up over estimating the number of samples per channels (it's not that huge usually, few samples)
<companion_cube>
You can just take a slice of the bigarray
<companion_cube>
It won't reallocate it
<discocaml>
<gabyfle> yes but it's not available as an FFI function (the slicing)
<discocaml>
<gabyfle> yes but it's not available as an FFI function (the slicing) (at least the bigarray.h header don't expose it)
dhil has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
LainIwakura has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]