companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
yosik has left #ocaml [Killed buffer]
germ has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
germ has joined #ocaml
Guest11 has joined #ocaml
Guest11 is now known as lixing
f[x] has quit [Remote host closed the connection]
f[x] has joined #ocaml
<lixing> can we add loongarch support in ocaml?
twobitsprite has joined #ocaml
twobitsp1ite has quit [Read error: Connection reset by peer]
bhoot has joined #ocaml
f[x] has quit [Remote host closed the connection]
<twobitsprite> What is the convention for creating a new .t from a module? I see Module.make and Module.create. E.g., Array.make and Array.create_float...
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
toastal has left #ocaml [Disconnected: Hibernating too long]
ansiwen has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
<discocaml> <Kali> make, usually
<twobitsprite> Thanks
<twobitsprite> When is .create_... used?
<discocaml> <darrenldl> my conclusion from last time i checked was vaguely "when the thing is mutable"
<discocaml> <darrenldl> i decided i don't care and just used make for everything, mutable or not
<twobitsprite> darrenldl: fair enough :P
bhoot has joined #ocaml
toastal has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
myrkraverk_ has quit [Read error: Connection reset by peer]
myrkraverk_ has joined #ocaml
Serpent7776 has joined #ocaml
alexherbo2 has joined #ocaml
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alexherbo2 has joined #ocaml
bhoot has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bartholin has joined #ocaml
toastal has quit [Ping timeout: 252 seconds]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
toastal has joined #ocaml
olle has joined #ocaml
mbuf has joined #ocaml
hannes has joined #ocaml
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
<reynir> ah yes, the List.make function
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
alexherbo2 has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
<discocaml> <qosmiof20> Hey lads, I haven't touched ocaml in years and i'm struggling a bit to setup a pleasant development environment.
<discocaml> <qosmiof20>
<discocaml> <qosmiof20> Are there no extensions that provide intellisense, formatting and type hinting?
alexherbo2 has quit [Remote host closed the connection]
<discocaml> <deepspacejohn> https://ocaml.org/docs/set-up-editor
<discocaml> <deepspacejohn> There are for VS Code, Vim, and Emacs. (Possibly others although IDK about them.)
<discocaml> <qosmiof20> This is nice, thank you.
<discocaml> <qosmiof20> How exactly do you run ocaml file? So far i've been running it from terminal but that's a bit tedious
<discocaml> <deepspacejohn> the generally recommended way is to use the Dune build system. Once you set up a dune project (you can see a minimal example on this page: https://dune.build/) you can execute `hello_world.ml` with `dune exec ./hello_world.exe`
<discocaml> <deepspacejohn> See also https://ocaml.org/docs/your-first-program
alexherbo2 has joined #ocaml
<discocaml> <._null._> twobitsprite: IIRC, create is for uninitialised structures, while make is the standard initialised variant
<discocaml> <qosmiof20> Can i also have another question:
<discocaml> <qosmiof20>
<discocaml> <qosmiof20> ```ocaml
<discocaml> <qosmiof20> let rec fill n =
<discocaml> <qosmiof20> if n = 1 then [1]
<discocaml> <qosmiof20> else fill (n - 1) @ [n]
<discocaml> <qosmiof20> ;;
<discocaml> <qosmiof20>
<discocaml> <qosmiof20> fill 5;;
<discocaml> <qosmiof20> ```
<discocaml> <qosmiof20> how come fill 5;; doesn't print anything like i'd expect it to in top level?
<discocaml> <qosmiof20> i'd like some output similar to this
<discocaml> <deepspacejohn> the top level has a special feature that prints the types and values of each command. if you want to print something in an executable, you'll have to do that yourself.
<discocaml> <qosmiof20> i see
<discocaml> <deepspacejohn> E.g. use `print_endline` or `Printf` or `Format` etc.
<discocaml> <qosmiof20> ```ocaml
<discocaml> <qosmiof20> let print_list list =
<discocaml> <qosmiof20> List.iter (fun n -> print_string ((string_of_int n) ^ ",")) list;;
<discocaml> <qosmiof20> ;;
<discocaml> <qosmiof20> ```
<discocaml> <qosmiof20> If i have a function like this, and would like to append a `print_newline` at the end but keep it in the print_list function, how would i go about that?
<discocaml> <qosmiof20> oh i forgot a single `;` can do the trick
<discocaml> <deepspacejohn> yes, either `;` or `let () = ... in print_newline ()`
<discocaml> <qosmiof20> ah, thank you
<discocaml> <qosmiof20> My professor once wrote this: `let times (a, b) = a * b in times (3, 5);;`
<discocaml> <qosmiof20> this doesn't seem very useful right?
<discocaml> <qosmiof20> if it's in the local scope
<discocaml> <qosmiof20> or did he mean just to demonstrate local scopes
<discocaml> <deepspacejohn> that exact example doesn't seem useful, but local scopes in general are very useful.
<discocaml> <qosmiof20> yeah i know local scopes are very useful but i was just wondering about this specific example since it makes no sense
<discocaml> <qosmiof20> thank you
waleee has joined #ocaml
dreadedfrog has quit [Remote host closed the connection]
<discocaml> <qosmiof20> ```ocaml
<discocaml> <qosmiof20> let rec reverse list = match list with
<discocaml> <qosmiof20> | [] -> []
<discocaml> <qosmiof20> | h::t -> (reverse t) @ [h]
<discocaml> <qosmiof20> ;;
<discocaml> <qosmiof20>
<discocaml> <qosmiof20> ```
<discocaml> <qosmiof20> this one wouldn't be tail recursive right?
waleee has quit [Ping timeout: 252 seconds]
<discocaml> <darrenldl> it would not be
<discocaml> <qosmiof20> i'm trying to write one that would be, i'll post when i manage to do it for rating
<discocaml> <darrenldl> code snippet reviews are better suited for #beginners or #advanced-help
alexherbo2 has quit [Remote host closed the connection]
deavmi has quit [Remote host closed the connection]
deavmi has joined #ocaml
deavmi has quit [Client Quit]
deavmi has joined #ocaml
deavmi has quit [Remote host closed the connection]
deavmi has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
hannes has quit [Quit: Lost terminal]
skyesoss has joined #ocaml
deavmi has quit [Remote host closed the connection]
deavmi has joined #ocaml
f[x] has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alexherbo2 has joined #ocaml
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
deavmi has quit [Remote host closed the connection]
Tuplanolla has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
deavmi has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Anarchos has joined #ocaml
bhoot has joined #ocaml
bhoot has quit [Client Quit]
bhoot has joined #ocaml
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
deadmarshal_ has quit [Remote host closed the connection]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mbuf has quit [Quit: Leaving]
bhoot has joined #ocaml
lixing has quit [Quit: Client closed]
deadmarshal_ has joined #ocaml
<Anarchos> what is the equivalent of the "try/finally" construction of Java ?
<companion_cube> Fun.protect
alexherbo2 has quit [Remote host closed the connection]
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bhoot has joined #ocaml
bhoot has quit [Quit: Textual IRC Client: www.textualapp.com]
skyesoss has quit [Quit: skyesoss]
<Anarchos> companion_cube thanks.
Anarchos has quit [Quit: Vision[]: i've been blurred!]
waleee has joined #ocaml
f[x] has quit [Remote host closed the connection]
user__ has joined #ocaml
<discocaml> <yawaramin> or just `try f (); finally () catch _ -> finally ()`
<discocaml> <Kali> (with, not catch)
<discocaml> <leviroth> Sort of, though if `finally ()` itself raises then the behavior is different.
<discocaml> <anmonteiro> it's try/with in OCaml
<discocaml> <Kali> just like match/with
<discocaml> <ada2k> or match x with exception exn ->
Serpent7776 has quit [Ping timeout: 248 seconds]
<discocaml> <yawaramin> or just `try f (); finally () with _ -> finally ()`
<discocaml> <yawaramin> what happens if the `finally` clause throws an exception in Java?
<discocaml> <leviroth> Idk. To be clear I wasn’t saying that your code is different from Java; I’m saying it’s different from Fun.protect.
<discocaml> <yawaramin> ok so i believe my suggestion replicates the behaviour of Java `try`/`finally` more closely than `Fun.protect`
<discocaml> <yawaramin> of course, that may not be very important for most cases
bartholin has quit [Quit: Leaving]
<discocaml> <leviroth> I don't think Java will execute the `finally` block twice if it raises an exception.
<discocaml> <leviroth> I think Java's behavior is more like `Fun.protect` than your code.
<companion_cube> It'll only run the finally part once but idk if it wraps the finally-raised exception if there's one
Tuplanolla has quit [Quit: Leaving.]
terrorjack4 has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack4 has joined #ocaml