<discocaml>
<crackcomm> I'm calling `time.sleep(10)` using pyml from `Async_unix.Thread_pool` and it blocks entire async event loop, what could be the reason? I'm clearly lacking some critical information
<discocaml>
<hockletock> does the python GIL stop everything?
<discocaml>
<crackcomm> GIL is locked but why would that block OCaml Async event loop?
<discocaml>
<crackcomm> I'm running the pyml code in a different thread
<discocaml>
<crackcomm> pyml doesn't seem to call `caml_enter_blocking_section` as an alias for `caml_release_runtime_system`, maybe it should?
<discocaml>
<Kali> `==` is for physical equality (by reference), not structural equality (by value)
<discocaml>
<Kali> use `=` for structural equality
<discocaml>
<.maverk> yayy it works
<discocaml>
<Kali> `;;` is unnecessary in a compiled file
<discocaml>
<Kali> it is only for terminating expressions in a toplevel
<discocaml>
<.maverk> so ``==`` when comparing memory addresses ?
<discocaml>
<Kali> yes
<discocaml>
<.maverk> i understand
<discocaml>
<.maverk> if i don't include ``;;`` it will show an error
<discocaml>
<Kali> that is because you have a toplevel `if`
<discocaml>
<Kali> ```ocaml
<discocaml>
<Kali> let name = "maverk"
<discocaml>
<Kali>
<discocaml>
<Kali> let () =
<discocaml>
<Kali> if name = "maverk"
<discocaml>
<Kali> then Printf.printf "true : maverk"
<discocaml>
<Kali> else Printf.printf "false : not maverk"
<discocaml>
<Kali> ```
<discocaml>
<.maverk> very interesting
<discocaml>
<.maverk> i like ocaml 😃
<discocaml>
<Kali> ocaml ignores whitespace, so if you have an expression at the toplevel, then it is really part of the last expression
<discocaml>
<Kali> that can be fixed by putting it into an appropriate let binding
<discocaml>
<Kali> such as the one above
<discocaml>
<.maverk> i do spaces for convention
<technomancy>
is it just as simple as "every top-level thing needs to be a let" or is there more to it than that?
<discocaml>
<.maverk> to avoid confusion
<discocaml>
<Kali> the spaces don't matter, it's the fact that you would be applying a string to a unit without the let-binding or ;;
<technomancy>
I don't feel like I've quite been able to put my finger on the rules for what's allowed; when you need semicolons, etc
<discocaml>
<Kali> technomancy: or a type/module declaration
<technomancy>
Kali: right; ok. cool, thanks.
<technomancy>
the point being, some kind of declaration, I guess
<discocaml>
<Kali> everything else should be a let-binding
<discocaml>
<Kali> `;` is to chain side effects
<discocaml>
<Kali> `;;` terminates an expression in the toplevel
<technomancy>
for a side-effect that's inside a function, is it better to use ; or to do a let () = whatever ?
<discocaml>
<Kali> `;` is more conventional
<discocaml>
<Kali> `;` has a more permissive warning than `let () = ` if you try to give it a non-unit value
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<discocaml>
<Kali> let () = correctly fails with a type error
<technomancy>
aha, makes sense
<companion_cube>
just use the flag -strict-sequence
<companion_cube>
always
<discocaml>
<.maverk> wait a minute what is this line suppose to tell me ?
<discocaml>
<.maverk>
<companion_cube>
(should be default really)
<discocaml>
<.maverk> ``let () = ``
<technomancy>
so it depends on how picky you're being about separating side-effects from values
<discocaml>
<Kali> it means that Printf.printf returns a unit
<discocaml>
<Kali> you are simply matching on a unit value
<technomancy>
companion_cube: so with that flag enabled, it's just two different notations for writing the same thing?
<discocaml>
<Kali> and since there is only one value of type unit, you can literally match it
<technomancy>
you could think of ; as syntactic sugar for let () = ... in ?
<discocaml>
<Kali> sure
<technomancy>
that's helpful
<technomancy>
normal people: "sure, I know what semicolons are for; makes perfect sense" / me: *overthinking it and getting confused*
<companion_cube>
th this flag, in `a; b`, `a:unit` is mandatory
<companion_cube>
I just find `;` more readable
<discocaml>
<Kali> easier to type
<discocaml>
<Kali> yeah
<discocaml>
<Kali> `;;` is strictly unnecessary in compiled files assuming all toplevel things are declarations of some sort (value, type, or module)
<technomancy>
the fact that ; only works inside a function kind of obscures the fact that otherwise they are equivalent
<technomancy>
at least, that's what confused me about it
<discocaml>
<Kali> does it not work outside of a function?
<discocaml>
<Kali> (rhetorical question)
<technomancy>
I thought you said that earlier
<discocaml>
<.maverk> and :: means it doesn't return a unit ?
<technomancy>
sorry, not outside a function, but rather at the top level
<discocaml>
<Kali> `;` does work at the toplevel, it's just not recommended to have expressions at the toplevel at all
<technomancy>
ah, I didn't realize that was just a recommendation, not a rule
<discocaml>
<octachron> `phrase;;` doesn't put any constraint on `phrase`.
<discocaml>
<octachron> which is useful in the REPL when you enter `1;;`, and error-prone outside of the REPL.
<discocaml>
<Kali> it is perfectly allowed to have them at top-level, it just means you need to write your code like it is in a repl, which looks gross (in my opinion) and can lead to errors if you forget ;;
<discocaml>
<._null._> technomancy: what's allowed at top-level (which is exactly the same as "module-level" is your usual definitions, type definitions, modules, module types and, expressions if separated from let-definitions (at least, maybe from other kinds of things too) by ;;
<discocaml>
<.maverk> i cannot import websocket
<discocaml>
<.maverk> i installed it
<discocaml>
<Kali> that's not how you import
<discocaml>
<._null._> That's not how you import stuff
<discocaml>
<.maverk> opam install websocket 2.15
<discocaml>
<.maverk> how ?
<discocaml>
<._null._> You link it at compile time (usually not manually)
<technomancy>
_null_ right, so there seems to be a difference depending on who you ask, haha
<technomancy>
"what does the language allow" vs "what do I personally think is permissable"
<discocaml>
<Kali> use `#require "websocket"` if you're running the file with `ocaml` or `utop`
<discocaml>
<._null._> I agree it's bad style to have top-level expressions, I still prefer to tell it's allowed
<discocaml>
<Kali> it is generally advisable to use a build system such as dune to link for you, however