<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)]
<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>
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)]