00:00
yosik has left #ocaml [Killed buffer]
00:30
germ has joined #ocaml
01:00
Guest11 has joined #ocaml
01:00
Guest11 is now known as lixing
01:42
f[x] has quit [Remote host closed the connection]
01:42
f[x] has joined #ocaml
01:50
<
lixing >
can we add loongarch support in ocaml?
02:08
twobitsprite has joined #ocaml
02:09
twobitsp1ite has quit [Read error: Connection reset by peer]
04:01
bhoot has joined #ocaml
04:03
f[x] has quit [Remote host closed the connection]
04:29
<
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...
04:41
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
04:58
toastal has left #ocaml [Disconnected: Hibernating too long]
05:02
ansiwen has joined #ocaml
05:05
<
discocaml >
<Kali> make, usually
05:05
<
twobitsprite >
Thanks
05:06
<
twobitsprite >
When is .create_... used?
05:08
<
discocaml >
<darrenldl> my conclusion from last time i checked was vaguely "when the thing is mutable"
05:08
<
discocaml >
<darrenldl> i decided i don't care and just used make for everything, mutable or not
05:09
<
twobitsprite >
darrenldl: fair enough :P
05:14
bhoot has joined #ocaml
05:30
toastal has joined #ocaml
05:39
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
06:31
myrkraverk_ has quit [Read error: Connection reset by peer]
06:31
myrkraverk_ has joined #ocaml
06:35
Serpent7776 has joined #ocaml
06:38
alexherbo2 has joined #ocaml
06:54
bhoot has joined #ocaml
06:56
bhoot has quit [Client Quit]
06:59
bhoot has joined #ocaml
07:17
alexherbo2 has quit [Remote host closed the connection]
07:17
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
07:17
alexherbo2 has joined #ocaml
07:18
bhoot has joined #ocaml
07:20
alexherbo2 has quit [Remote host closed the connection]
07:31
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
07:31
bhoot has joined #ocaml
07:32
bartholin has joined #ocaml
07:57
toastal has quit [Ping timeout: 252 seconds]
08:04
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:05
bhoot has joined #ocaml
08:11
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:14
toastal has joined #ocaml
08:16
olle has joined #ocaml
08:16
mbuf has joined #ocaml
08:25
hannes has joined #ocaml
08:30
bhoot has joined #ocaml
08:32
bhoot has quit [Client Quit]
08:32
bhoot has joined #ocaml
08:37
bhoot has quit [Client Quit]
08:38
bhoot has joined #ocaml
08:54
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
08:57
bhoot has joined #ocaml
09:07
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:08
bhoot has joined #ocaml
09:17
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:18
bhoot has joined #ocaml
09:31
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:32
bhoot has joined #ocaml
09:37
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
09:39
bhoot has joined #ocaml
09:49
<
reynir >
ah yes, the List.make function
10:08
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:14
bhoot has joined #ocaml
10:16
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
10:46
alexherbo2 has joined #ocaml
10:47
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:47
bhoot has joined #ocaml
10:58
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:59
bhoot has joined #ocaml
11:02
<
discocaml >
<qosmiof20> Hey lads, I haven't touched ocaml in years and i'm struggling a bit to setup a pleasant development environment.
11:02
<
discocaml >
<qosmiof20>
11:02
<
discocaml >
<qosmiof20> Are there no extensions that provide intellisense, formatting and type hinting?
11:21
alexherbo2 has quit [Remote host closed the connection]
11:24
<
discocaml >
<deepspacejohn> There are for VS Code, Vim, and Emacs. (Possibly others although IDK about them.)
11:26
<
discocaml >
<qosmiof20> This is nice, thank you.
11:26
<
discocaml >
<qosmiof20> How exactly do you run ocaml file? So far i've been running it from terminal but that's a bit tedious
11:28
<
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`
11:46
alexherbo2 has joined #ocaml
11:47
<
discocaml >
<._null._> twobitsprite: IIRC, create is for uninitialised structures, while make is the standard initialised variant
11:47
<
discocaml >
<qosmiof20> Can i also have another question:
11:47
<
discocaml >
<qosmiof20>
11:47
<
discocaml >
<qosmiof20> ```ocaml
11:47
<
discocaml >
<qosmiof20> let rec fill n =
11:47
<
discocaml >
<qosmiof20> if n = 1 then [1]
11:47
<
discocaml >
<qosmiof20> else fill (n - 1) @ [n]
11:48
<
discocaml >
<qosmiof20> ;;
11:48
<
discocaml >
<qosmiof20>
11:48
<
discocaml >
<qosmiof20> fill 5;;
11:48
<
discocaml >
<qosmiof20> ```
11:48
<
discocaml >
<qosmiof20> how come fill 5;; doesn't print anything like i'd expect it to in top level?
11:48
<
discocaml >
<qosmiof20> i'd like some output similar to this
11:50
<
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.
11:50
<
discocaml >
<qosmiof20> i see
11:50
<
discocaml >
<deepspacejohn> E.g. use `print_endline` or `Printf` or `Format` etc.
11:57
<
discocaml >
<qosmiof20> ```ocaml
11:57
<
discocaml >
<qosmiof20> let print_list list =
11:57
<
discocaml >
<qosmiof20> List.iter (fun n -> print_string ((string_of_int n) ^ ",")) list;;
11:57
<
discocaml >
<qosmiof20> ;;
11:57
<
discocaml >
<qosmiof20> ```
11:57
<
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?
11:58
<
discocaml >
<qosmiof20> oh i forgot a single `;` can do the trick
11:58
<
discocaml >
<deepspacejohn> yes, either `;` or `let () = ... in print_newline ()`
11:58
<
discocaml >
<qosmiof20> ah, thank you
11:59
<
discocaml >
<qosmiof20> My professor once wrote this: `let times (a, b) = a * b in times (3, 5);;`
11:59
<
discocaml >
<qosmiof20> this doesn't seem very useful right?
11:59
<
discocaml >
<qosmiof20> if it's in the local scope
11:59
<
discocaml >
<qosmiof20> or did he mean just to demonstrate local scopes
12:00
<
discocaml >
<deepspacejohn> that exact example doesn't seem useful, but local scopes in general are very useful.
12:02
<
discocaml >
<qosmiof20> yeah i know local scopes are very useful but i was just wondering about this specific example since it makes no sense
12:02
<
discocaml >
<qosmiof20> thank you
12:05
waleee has joined #ocaml
12:10
dreadedfrog has quit [Remote host closed the connection]
12:11
<
discocaml >
<qosmiof20> ```ocaml
12:11
<
discocaml >
<qosmiof20> let rec reverse list = match list with
12:11
<
discocaml >
<qosmiof20> | [] -> []
12:11
<
discocaml >
<qosmiof20> | h::t -> (reverse t) @ [h]
12:11
<
discocaml >
<qosmiof20> ;;
12:11
<
discocaml >
<qosmiof20>
12:11
<
discocaml >
<qosmiof20> ```
12:11
<
discocaml >
<qosmiof20> this one wouldn't be tail recursive right?
12:19
waleee has quit [Ping timeout: 252 seconds]
12:22
<
discocaml >
<darrenldl> it would not be
12:27
<
discocaml >
<qosmiof20> i'm trying to write one that would be, i'll post when i manage to do it for rating
12:28
<
discocaml >
<darrenldl> code snippet reviews are better suited for #beginners or #advanced-help
12:31
alexherbo2 has quit [Remote host closed the connection]
12:43
deavmi has quit [Remote host closed the connection]
12:44
deavmi has joined #ocaml
12:45
deavmi has quit [Client Quit]
12:47
deavmi has joined #ocaml
12:48
deavmi has quit [Remote host closed the connection]
12:55
deavmi has joined #ocaml
12:58
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
13:02
bhoot has joined #ocaml
13:03
bhoot has quit [Client Quit]
13:04
bhoot has joined #ocaml
13:46
hannes has quit [Quit: Lost terminal]
13:51
skyesoss has joined #ocaml
14:15
deavmi has quit [Remote host closed the connection]
14:20
deavmi has joined #ocaml
14:29
f[x] has joined #ocaml
15:10
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
15:12
bhoot has joined #ocaml
15:49
olle has quit [Ping timeout: 260 seconds]
15:56
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
16:07
alexherbo2 has joined #ocaml
16:25
bhoot has joined #ocaml
16:27
bhoot has quit [Client Quit]
16:31
bhoot has joined #ocaml
16:35
deavmi has quit [Remote host closed the connection]
16:40
Tuplanolla has joined #ocaml
16:43
alexherbo2 has quit [Remote host closed the connection]
16:47
alexherbo2 has joined #ocaml
17:23
deavmi has joined #ocaml
17:50
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
17:51
Anarchos has joined #ocaml
17:51
bhoot has joined #ocaml
17:52
bhoot has quit [Client Quit]
18:01
bhoot has joined #ocaml
18:11
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:12
bhoot has joined #ocaml
18:30
deadmarshal_ has quit [Remote host closed the connection]
18:34
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
18:38
mbuf has quit [Quit: Leaving]
18:47
bhoot has joined #ocaml
19:03
lixing has quit [Quit: Client closed]
19:07
deadmarshal_ has joined #ocaml
19:27
<
Anarchos >
what is the equivalent of the "try/finally" construction of Java ?
19:31
<
companion_cube >
Fun.protect
19:35
alexherbo2 has quit [Remote host closed the connection]
19:59
bhoot has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
19:59
bhoot has joined #ocaml
20:13
skyesoss has quit [Quit: skyesoss]
20:17
<
Anarchos >
companion_cube thanks.
20:18
Anarchos has quit [Quit: Vision[]: i've been blurred!]
20:43
waleee has joined #ocaml
21:35
f[x] has quit [Remote host closed the connection]
21:35
user__ has joined #ocaml
21:54
<
discocaml >
<yawaramin> or just `try f (); finally () catch _ -> finally ()`
22:03
<
discocaml >
<Kali> (with, not catch)
22:03
<
discocaml >
<leviroth> Sort of, though if `finally ()` itself raises then the behavior is different.
22:04
<
discocaml >
<anmonteiro> it's try/with in OCaml
22:04
<
discocaml >
<Kali> just like match/with
22:06
<
discocaml >
<ada2k> or match x with exception exn ->
22:13
Serpent7776 has quit [Ping timeout: 248 seconds]
22:23
<
discocaml >
<yawaramin> or just `try f (); finally () with _ -> finally ()`
22:24
<
discocaml >
<yawaramin> what happens if the `finally` clause throws an exception in Java?
22:31
<
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.
22:37
<
discocaml >
<yawaramin> ok so i believe my suggestion replicates the behaviour of Java `try`/`finally` more closely than `Fun.protect`
22:38
<
discocaml >
<yawaramin> of course, that may not be very important for most cases
22:44
bartholin has quit [Quit: Leaving]
23:04
<
discocaml >
<leviroth> I don't think Java will execute the `finally` block twice if it raises an exception.
23:04
<
discocaml >
<leviroth> I think Java's behavior is more like `Fun.protect` than your code.
23:06
<
companion_cube >
It'll only run the finally part once but idk if it wraps the finally-raised exception if there's one
23:47
Tuplanolla has quit [Quit: Leaving.]
23:55
terrorjack4 has joined #ocaml