rwmjones changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.1 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
hsuh has quit [Remote closed the connection]
hsuh has joined #ocaml
zmdkrbou has quit [Read error: 110 (Connection timed out)]
mwc has joined #ocaml
zmdkrbou has joined #ocaml
nashdj has joined #ocaml
<Yoric[DT]> Well, time to sleep.
<Yoric[DT]> If anybody's interested, the first 29 pages of my OCaml tutorial (in French) are available on wikibooks : http://fr.wikibooks.org/wiki/Objective_Caml .
<hsuh> are you translating some material?
<hsuh> (e.g., your tutorial in english)
Yoric[DT] has quit ["Ex-Chat"]
<Snrrrub> Could anyone provide some hints on when one would use modules vs. classes? In my simplistic program, they're roughly equivalent (except the module's functions require an explicit 'self' parameter)
<Snrrrub> For example, if I were writing a rectangle data type with functions that manipulate it (e.g. create, overlaps, etc.), what criteria (sh|w)ould I use to evaluate the use of modules vs. classes?
<Smerdyakov> Most OCaml programmers try to avoid classes whenever possible.
<Snrrrub> Is that mostly just preference or is there some merit to that approach?
ita has joined #ocaml
<Smerdyakov> I don't have the energy to explain it now, but it's not "just preference."
<Snrrrub> Fair enough. If you know of online resources that could explain the difference off the top of your head, I'd appreciate it.
nashdj has quit [Read error: 110 (Connection timed out)]
leo037 has quit ["Leaving"]
ita has quit [Read error: 110 (Connection timed out)]
thermoplyae has quit ["daddy's in space"]
seafood_ has joined #ocaml
jlouis has quit [Remote closed the connection]
jlouis has joined #ocaml
zmdkrbou has quit [Read error: 110 (Connection timed out)]
buluca has quit ["Leaving."]
hsuh has quit ["bye emacs"]
Snrrrub has quit [Read error: 104 (Connection reset by peer)]
<mwc> Ahh, Snrrrub quit
zmdkrbou has joined #ocaml
Snrrrub has joined #ocaml
<Snrrrub> If I have a type t = { a:int } and type u = { a:int; b:int } then how do I tell the type inference system which type to use in a function like: let f x y = x.a = y.a && y.b != 0 (where I *want* x:t and y:u)
<tsuyoshi> that would be impossible
<tsuyoshi> if you define two record types with the same field name, the last one defined is used
<Snrrrub> So (roughly speaking) there's just a single namespace for record names?
<tsuyoshi> so what you want to do usually is either add a "t_" or "u_" to the beginning of the field name
<tsuyoshi> or you can create a module for each record type
<tsuyoshi> snrrrub: well, a single namespace for field names
<Snrrrub> whoops, yes, that was supposed to be "field" not "record". I see. Well, that changes a few things. Thanks!
<tsuyoshi> it's because of the type inference.. if you do "x.y" it needs to figure out the type from "y"
<Snrrrub> Yeah, I was just wondering if there was a way to explicitly specify the type in an ambiguous scenario.
<tsuyoshi> if you have it in a separate module.. you do like "x.Module.y"
<Snrrrub> Actually, I do have two modules but I'm attempting to access one type from the other :)
<Snrrrub> Maybe I'll just have to be sneaky. >_>
mwc has quit ["Leaving"]
thermoplyae has joined #ocaml
olleolleolle has joined #ocaml
AxleLonghorn has joined #ocaml
ttamttam has joined #ocaml
AxleLonghorn has left #ocaml []
thermoplyae has quit ["daddy's in space"]
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
seafood_ has quit []
Yoric[DT] has joined #ocaml
<Yoric[DT]> hi
filp has joined #ocaml
mrsolo has quit ["Leaving"]
Snark has joined #ocaml
Snark_ has joined #ocaml
Snark_ has quit [Read error: 104 (Connection reset by peer)]
olleolleolle has quit []
seafood_ has joined #ocaml
Tetsuo has joined #ocaml
olleolleolle has joined #ocaml
seafood_ has quit []
Yoric[DT] has quit ["Ex-Chat"]
hkBst has joined #ocaml
Sparkles has quit [Remote closed the connection]
Yoric[DT] has joined #ocaml
rwmjones has joined #ocaml
Torment has quit [Read error: 110 (Connection timed out)]
olleolleolle has quit []
asmanur has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
seafood_ has joined #ocaml
leo037 has joined #ocaml
pango_ has quit [Remote closed the connection]
pango_ has joined #ocaml
olleolleolle has joined #ocaml
ttamttam has left #ocaml []
buluca has joined #ocaml
Associat0r has quit []
filp has quit ["Bye"]
pango_ has quit [Remote closed the connection]
filp has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
pango_ has joined #ocaml
bzzbzz has joined #ocaml
seafood_ has quit [Read error: 110 (Connection timed out)]
musically_ut has joined #ocaml
sergez has joined #ocaml
RobertFischer has joined #ocaml
sergez has quit [Read error: 131 (Connection reset by peer)]
sergez has joined #ocaml
musically has joined #ocaml
musically_ut has quit ["Leaving"]
ita has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit [Read error: 113 (No route to host)]
ttamttam has joined #ocaml
sergez has quit [No route to host]
Illocution has quit ["oh termcap, why can't we all just get along"]
leo037_ has joined #ocaml
Illocution has joined #ocaml
leo037 has quit [Read error: 110 (Connection timed out)]
zmdkrbou has quit [Read error: 110 (Connection timed out)]
madroach has joined #ocaml
ttamttam has left #ocaml []
sergez has joined #ocaml
middayc has joined #ocaml
olleolleolle has quit []
leo037_ is now known as leo037
sergez has quit [Read error: 113 (No route to host)]
pango_ has quit [Remote closed the connection]
olleolleolle has joined #ocaml
pango_ has joined #ocaml
Snrrrub has quit [Read error: 104 (Connection reset by peer)]
ita is now known as ita|nap
Tetsuo has quit ["Leaving"]
filp has quit ["Bye"]
sergez has joined #ocaml
dramsay has joined #ocaml
sergez has quit [Read error: 60 (Operation timed out)]
olleolleolle has quit []
buluca has joined #ocaml
ita|nap has quit [Read error: 110 (Connection timed out)]
madroac1 has joined #ocaml
madroach has quit [Read error: 113 (No route to host)]
<musically> Am a newcomer learning Ocaml, need a few comments on my first Ocaml code. (If you find anything wrong, I like it served hard.) Thanks. http://pastebin.com/d4b78ffaf
<asmanur> musically: print_all_gauss seems to be useless, do you know List.iter ?
<musically> Ah .. List.iter (printf "%f\n" ) ( List.map gauss_one params);; ?
<musically> asmanur: ?
<asmanur> musically: yes
<musically> Thanks. Point noted.
<asmanur> musically: about the style, open are often evil
<musically> Specifically I wanted to know whether the ... "opens are a good idea" :)
<asmanur> musically: open the standard module are often not a so good idea
<musically> And the dealing of uint is correct? As in let () = print..... ?
<asmanur> musically: you can replace a few let () = by using the operator ';'
<asmanur> Printf.printf "\n\n\n"; print_all_gauss ... for instance
<asmanur> (let () = are often used in the middle of let ... in lists and ; at the end of a functions)
<asmanur> musically: the ';;' are also unneeded, so you can remove them if you want
<musically> Oh .. I didn't know that.
<musically> I have been playing with the interactive environment too long, I guess.
<asmanur> musically: and, we often define pi as 4.0 * atan (1.) instead of putting an appromixation
<asmanur> (I guess it's not very ocaml-specific)
<musically> asmanur: I see, I was looking for a static definition of pi in the math module ... but found out that java like names don't exist here ...
<asmanur> java like names ?
<musically> Math.pi
<asmanur> oh
<asmanur> musically: you have such identifiers in ocaml
<asmanur> but, if you open modules, you won't have it :)
<musically> Ouch ..
<asmanur> of example Printf.printf
<asmanur> for*
* qwr . o O ( i've never used let () = ... in )
<musically> asmanur: printf "\n\n\n"; print_all_gauss ( List.map gauss_one params);; throws me an error.
<musically> I am putting it on pastebin
<musically> Maybe you can tell me what I did wrong.
<petchema> from style point of view, get_list is rather horrible (input, output and building a list, all-in-one... mmmh)
<musically> asmanur: The last two lines.
<musically> petchema: Can you suggest what it should have been like? This is the first time I am taking input from the user in an Ocaml program.
<asmanur> musically: actually it's not these lines :)
<asmanur> let () = printf "%f\n" in print_all_gauss tl;
rwmjones has left #ocaml []
<asmanur> no ';' just before a 'in'
<asmanur> syntax is : foo ; bar
<asmanur> (where foo and bar are two expressions that should be of type unit)
<petchema> musically: for that kind of usage it's better to use OCaml interactively in the first place
<musically> petchema: You mean taking inputs should be done only in the interactive mode?
<petchema> musically: at least, that's what I'd do. Requiring to enter values one by one is the worse possible interface
<musically> petchema: I understand, but the input will be fed from a file.
<qwr> hmm. and if you have known number of iterations, for would have done fine.
<musically> qwr: I wanted to get a taste of the Functional programming style before going the imperative way.
<qwr> ok ;)
<musically> (That is a different way of saying that I don't yet know how to use for as easily yet)
<musically> :)
sergez has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
<musically> asmanur: I am afraid the syntax is giving me a real trouble. Can you help me out a bit there? Maybe post it on the pastebin ?
<qwr> musically: what syntax?
<asmanur> musically: what do you not understand ? ';' is like the ',' in C
<musically> asmanur: Thanks, got it.
<qwr> asmanur: btw, printf "%f\n" 6.66;
<qwr> s/asmanur/musically/
<qwr> each % wants a argument
<musically> Thanks qwr, I found the error, and the statement that ; works like , in C cleared all doubts.
<asmanur> By the way, does anybody know the « functionnal reactive programming ». I'm playing with it, it seems very fun
<asmanur> (I'm writing a small implementation in OCaml from the one in haskell)
<jonafan> there's an implementation called Fr i think
<jonafan> i guess it's called ocaml rt
<asmanur> ok, thanks
<musically> qwr: BTW, how do you handle the uint's returned from the side-effect only functions?
ttamttam has joined #ocaml
darinm has joined #ocaml
<jonafan> i've been meaning to learn more about functional reactive programming
<jonafan> it seems like something i'd dig
<qwr> musically: hmm. what do you mean by handling them?
<qwr> musically: some example please :)
<asmanur> jonafan: it seems interesting, the implementation I'm writing is designed rather to create games than GUI (but the core is generic)
<jonafan> ah, cool
<musically> qwr: If you can rewrite a few places in my program where I have had to use let () = print.... it'll be helpful.
<qwr> musically: () type is called unit, not uint :)
<musically> Oh .. my bad.
<musically> int comes far more naturally than unit, I am afraid :)
<qwr> musically: http://pastebin.com/m9b8eb24 but i didn't try to compile it - so be warned about typos
<qwr> musically: and by moveing init 10 after functions you can have even fewer ;; http://pastebin.com/m6b57e0b
* qwr don't like those ;; too much when reading code
<musically> qwr: Sweet
<musically> It _looks_ much better now.
sergez has quit [Read error: 113 (No route to host)]
RobertFischer has left #ocaml []
* qwr . o O ( and match matches don't need ; after them... http://pastebin.com/m3a9a2602 )
<musically> qwr: Works, indeed. :)
<musically> Quite ingenious I would say, though I haven't seen a lot of Ocaml code as yet, but it looks intreguing.
<musically> If left to myself, I would have complained that the first two let would require either a ;; or a in after them.
madroac1 has quit [Remote closed the connection]
Morphous_ has joined #ocaml
sergez has joined #ocaml
jderque has joined #ocaml
Morphous has quit [Read error: 110 (Connection timed out)]
sergez has quit [Read error: 60 (Operation timed out)]
darinm has quit []
ygrek has joined #ocaml
darinm has joined #ocaml
musically has quit ["Leaving"]
musically has joined #ocaml
<jonafan> why do people always recommend removing ;;s?
<musically> jonafan: Makes code easier to read, I think.
<jonafan> i don't agree
<musically> Well, it made my code much much better, and I think ;; is fit only for interactive mode.
<musically> I don't think that I want it for file based programming.
<jonafan> i would rather use the same style in both contexts
<jonafan> besides, ;;s are just more info for the compiler
<pango_> jonafan: little info however; I used for a while ;; in my programs each time I reached "toplevel", and IIRC sometimes the compiler was perfectly ok with ;; within some expressions
<pango_> (which was disappointing)
<jonafan> within expressions defining objects perhaps
<pango_> probably not, I've yet to use OCaml's OO
<jonafan> i'd like to see these statements
<jonafan> anyway, i think this is one of the least pressing things to tell a newbie
sergez has joined #ocaml
asmanur has quit [Remote closed the connection]
<pango_> agreed. I've seen people recommending that style
darinm has quit []
ita|nap has joined #ocaml
darinm has joined #ocaml
ita|nap is now known as ita
darinm has quit []
sergez has quit [Read error: 113 (No route to host)]
Yoric[DT] has joined #ocaml
ttamttam has left #ocaml []
ttamttam has joined #ocaml
ttamttam has left #ocaml []
Associat0r has joined #ocaml
Snark has quit ["Ex-Chat"]
ygrek has quit [Remote closed the connection]
ygrek_ has joined #ocaml
sergez has joined #ocaml
sergez has quit [Read error: 148 (No route to host)]
<JesusChrist2008> hello
<JesusChrist2008> is still used caml-light?
<Yoric[DT]> In some classes.
<JesusChrist2008> i think the caml-light language is more easy than ocaml
<JesusChrist2008> OO is complex
thermoplyae has joined #ocaml
<JesusChrist2008> and confuse
<pango_> JesusChrist2008: I'm using OCaml and never used its OO part
<pango_> it's quite easy to avoid it
<pango_> and mostly redundant
<Yoric[DT]> JesusChrist2008: you don't need to use OO.
<Yoric[DT]> (most people never do)
<JesusChrist2008> thanks
<JesusChrist2008> i want to write a program, do i it in caml-light? Any recommendation?
jderque has quit [Read error: 113 (No route to host)]
<pango_> the compiler doesn't seem actively maintained (latest release 6 years old), you'd need better reasons that "OCaml is more featured" to not to use it
<pango_> s/that/than/
<pango_> while the languages are very similar, I'm sure the largest community of people using OCaml should be taken into consideration too
<Yoric[DT]> Really, use OCaml.
<JesusChrist2008> ok
leo037 has quit ["big bisou forever"]
ygrek_ has quit [Remote closed the connection]
sergez has joined #ocaml
musically has quit [Remote closed the connection]
zmdkrbou has joined #ocaml
middayc has quit []
sergez has quit [Read error: 113 (No route to host)]
smimram has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
Morphous_ is now known as Amorphous
ita has quit [Read error: 110 (Connection timed out)]
dramsay has quit ["Leaving"]
middayc has joined #ocaml
sergez has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
buluca has joined #ocaml
sergez has quit [Read error: 113 (No route to host)]
Mr_Awesome has quit [Connection timed out]
hkBst has quit ["Konversation terminated!"]
sergez has joined #ocaml
seafood_ has joined #ocaml
sergez has quit [Read error: 60 (Operation timed out)]
middayc has quit []