faultline has quit [Remote host closed the connection]
waleee has quit [Ping timeout: 260 seconds]
bobo has quit [Ping timeout: 264 seconds]
zebrag has quit [Quit: Konversation terminated!]
gravicappa has joined #ocaml
bobo has joined #ocaml
cbarrett has quit [Ping timeout: 260 seconds]
JSharp has quit [Ping timeout: 264 seconds]
kevinsjoberg has quit [Ping timeout: 260 seconds]
jyc has quit [Ping timeout: 260 seconds]
kevinsjoberg has joined #ocaml
JSharp has joined #ocaml
jyc has joined #ocaml
cbarrett has joined #ocaml
recherche has joined #ocaml
<recherche>
is there is a way to get ocamldebug working well with code that is preprocessed using -pp (say, cppo)? i can't seem to set breakpoints accurately with line directives, sometimes get locations hundreds of lines away instead. and not using line directives exposes temporary filenames, so breakpoints can't be set at all
recherche has quit [Quit: Ping timeout (120 seconds)]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
gravicappa has quit [Ping timeout: 260 seconds]
recherche has joined #ocaml
<hornhack>
hi, is ocaml code easier to read than common imperative code? like tail recursion vs common loop?
hendursaga has joined #ocaml
hendursa1 has quit [Ping timeout: 276 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #ocaml
bartholin has joined #ocaml
recherche has quit [Quit: Client closed]
average has joined #ocaml
greenbagels_ is now known as greenbagels
wonko has joined #ocaml
olle has joined #ocaml
mro has joined #ocaml
<d_bot>
<۞๑,¸,ø¤º`°๑۩ ןєคภ ๑۩ ,¸,ø¤º`°๑۞> I understand there is some problem with parsing applications rules (x y z is ambiguous), but how can I solve this ?
<dmbaturin_>
hornhack: You can write imperative code in OCaml. :)
<hornhack>
yeah, I just think they are not in the spirit of functional programming
<dmbaturin_>
Anyway, by now I find pure code easier to follow, generally. But there are many ways to make pure code hard to read, like breaking it into functions too small for their own good that obscure the data flow, or by excessive use of point-free style (the latter is harder in OCaml, for better or worse).
dmbaturin_ is now known as dmbaturin
<hornhack>
ehh point-free style?
<d_bot>
<idkjs> hey folks. Doing this old ocaml course on udemy. the following is expected to print with comments but does not. Its probably been updated. How do you get print with comments in utop. This doesnt seem to work ```ocaml
<d_bot>
<idkjs> I was thinking the comment would print. What is the point of the comment if it doesnt show?
<dmbaturin>
Well, it's just for the reader I guess.
<d_bot>
<idkjs> But I havent saved it anywhere. its just in utop so no one will ever see it i guess. Just for me?
<dmbaturin>
Like those cheesy martial arts movies where people call all their attacks. ;)
<dmbaturin>
I think the author of that example thought it will help students follow the utop session transcript.
<d_bot>
<idkjs> So this ```ocaml
<d_bot>
<idkjs> utop # let x = 10;;
<d_bot>
<idkjs> if x > 5 then print_string "greater than 5"
<d_bot>
<idkjs> else print_string "less than 5" (*conditional statement*);;
<d_bot>
<idkjs>
<d_bot>
<idkjs> ``` outputs ```ocaml
<d_bot>
<idkjs> val x : int = 10
<d_bot>
<idkjs> ``` when expected ```ocaml
<d_bot>
<idkjs> val x : int = 10
<d_bot>
<idkjs> # greater than 5- : unit = ()
<d_bot>
<idkjs> ``` what am i missing? Some config maybe?
<dmbaturin>
hornhack: The curious part is that pure code is a relatively recent fashion. A lot of old ML code looks like Pascal with first-class functions.
<hornhack>
dmbaturin, wow, really, I didnt know that
<hornhack>
I thought OCaml was born for functional programming
<dmbaturin>
idjks: That utop behaviour with two statements on the same input line is interesting... This will work as expected `let x = 10 in if x > 5 then print_string "greater than 5" else print_string "less than 5";;`. Writing `let x = 10;;` and then enxtering `print ...` as a separate command also works.
<dmbaturin>
Let me check something...
<d_bot>
<idkjs> That worked but not the same code as you seem to have noted ```ocaml
<d_bot>
<idkjs> greater than 5- : unit = ()
<d_bot>
<idkjs> ```
<dmbaturin>
Looks like utop ignores the part after ;; on the same line. Time for a bug report. :)
<d_bot>
<idkjs> Doesnt work with a comment either ```ocaml
<d_bot>
<idkjs> utop # let x = 10 in if x > 5 then print_string "greater than 5" else print_string "less than 5" (*conditional statement*);;
<d_bot>
<idkjs> greater than 5- : unit = ()
<d_bot>
<idkjs> ```
<dmbaturin>
hornhack: Well, in the 80's, the idea of first-class functions in a practical language was itself still sounded like radically functional programming I guess.
<hornhack>
woo, yeahh
<dmbaturin>
You may be interested in the "ZINC report". The group that made CAML Light (the direct predecessor of OCaml) came up with an efficient implementation of closures in the early 90's that allowed functional programming idioms to be fast.
<hornhack>
wow nice
<hornhack>
eh, let me check what is closure
<dmbaturin>
I'm not quite sure when the first non-toy programs in aggressively functional style appeared.
<dmbaturin>
A closure is a function stored together with its environment. That's how currying works, e.g. `let add1 x = (+) x 1`, here the `(+)` function will be stored with `x = 1` in its environment.
<d_bot>
<idkjs> should i do that? Or are you going to do that?
<dmbaturin>
I suppose their implementation of closures was the reason OCaml had everything curried by default. In StandardML, most stdlib functions take tuples instead, so it's `(+): int * int -> int` rather than OCaml's `(+) : int -> int -> int`.
<hornhack>
ah I see
<hornhack>
so functional works because they made closure fast
<dmbaturin>
idjks: I'll do that since I have a reproducing step handy now.
rond_ has quit [Quit: Client closed]
<d_bot>
<darrenldl> interesting development of fp : O
<dmbaturin>
idkjs: Do you have a link to that course? Could you take a screenshot of the example, are they actually using those statements on the same line? I wonder if it did work when the course was made.
mro has quit [Remote host closed the connection]
<dmbaturin>
hornhack: https://github.com/SKS-Keyserver/sks-keyserver The SKS key server is one of the oldest OCaml programs in use. That code is mostly functional, but still more imperative than if it was written today. I'll try to remember of the more unashamerly imperative examples.
<dmbaturin>
* remember more unashamedly imperative
<dmbaturin>
Looks like I'm dyslexic today. ;)
<octachron>
The OCaml compiler is fairly imperative itself
<hornhack>
hehe interesting
<hornhack>
wow thats hypocritical, the compiler is imperative
<octachron>
Type inference is done using union-find, and generalization is implented as a form of GC on type variables.
<octachron>
Hypocritical??? Not at all. The compiler is never using OCaml feature not available to non-compiler program.
<octachron>
Using imperative features internally when it make sense for performance reason is a pretty common way to organize OCaml library/program.
<dmbaturin>
I think it's an advantage of the language that you can write it to make it look like either Pascal or Haskell and still end up with a reasonably fast program. ;)
<d_bot>
<Drup> The imperative features are there to be used. If not, they wouldn't be there. So the compiler (and many users) indeed do use them 🙂
<Corbin>
hornhack: Is it hypocritical to use a CPU wired up to mutable memory to implement immutable programs? Is it hypocritical for the values in the CPU registers to each be immutable?
<dmbaturin>
When I have time, I swear I'll make PoC stdlib that uses objects to make it look like Python.
<dmbaturin>
Hopefully this summer when (or if...) I graduate.
<d_bot>
<Drup> dmbaturin: people have done that previously! I don't remember the name though
<d_bot>
<Drup> it wasn't nice
<dmbaturin>
Wow, interesting. Let me know if you remember the name.
<d_bot>
<Drup> But A+ troll :p
<d_bot>
<Drup> mmh, @companion_cube Does that ring a bell ? of course there are pieces of batteries that are a bit weird like that (IO, notably), but not the whole thing
<dmbaturin>
Drup: Did it use a set of "magic methods" with standard types as an object communication protocol?
<d_bot>
<Drup> I don't remember the details, but it really looked liked python objects
favonia has quit [Remote host closed the connection]
favonia has joined #ocaml
jlrnick has joined #ocaml
<companion_cube>
Drup: rings a bell but was a long time ago
<companion_cube>
Sadly ocaml doesn't have great control flow primitives for imperative
<dmbaturin>
companion_cube: I'm pretty sure some would say s/sadly/thankfully/ :)
<companion_cube>
My own ocaml tends to be very imperative at places, so, no, sad :/
bartholin has quit [Ping timeout: 264 seconds]
hendursaga has quit [Remote host closed the connection]