Xolution has joined #ocaml
mimosa has quit ["I like core dumps"]
gim has quit ["bn"]
pattern has joined #ocaml
lus|wazze has quit ["If we don't believe in freedom of expression for people we despise, we don't believe in it at all -- Noam Chomsky"]
Kinners has joined #ocaml
buggs is now known as buggs|afk
pattern has quit [Read error: 110 (Connection timed out)]
Kinners has left #ocaml []
ez4 has joined #ocaml
Xolution has quit ["The riot be the rhyme of the unheard."]
pattern has joined #ocaml
Herrchen has quit [Read error: 110 (Connection timed out)]
pattern has quit [Read error: 110 (Connection timed out)]
pattern has joined #ocaml
pattern has quit ["..."]
<
Etaoin>
anyone around?
<
Etaoin>
know much about oo?
brwill is now known as brwill_zzz
<
Etaoin>
how do I have an object accept a subclass of itself as an argument to one of its methods?
durnew has left #ocaml []
<
karryall>
Etaoin: in general, you can't
Defcon7 has quit [Remote closed the connection]
Defcon7 has joined #ocaml
lam has joined #ocaml
gim has joined #ocaml
mimosa has joined #ocaml
two-face has joined #ocaml
Demitar has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
__buggs has joined #ocaml
Herrchen has joined #ocaml
buggs|afk has quit [Read error: 110 (Connection timed out)]
__buggs has quit ["maybe it crashed"]
karryall has quit [Nick collision from services.]
karryall has joined #ocaml
mattam_ is now known as mattam
two-face has left #ocaml []
smkl has quit ["Client exiting"]
Ekimoz3 has joined #ocaml
smkl has joined #ocaml
<
Ekimoz3>
I am a new user of ocaml
<
Ekimoz3>
I use it with Linux
<
Ekimoz3>
Heho, where you are ?
<
Ekimoz3>
Am i the only logged ?
Ekimoz3 has left #ocaml []
<
karryall>
tss... 'sont pas patients ces ptits jeunes
<
karryall>
c'est où Paris 8 ?
<
smkl>
uhh, at Paris?
<
karryall>
no ;), it's in Saint-Denis apparently
gim has quit ["faut bien qu'il se deplace un peu ce pauvre portable :)"]
buggs has joined #ocaml
lus|wazze has joined #ocaml
avn has quit [Read error: 113 (No route to host)]
Maddas_ is now known as Maddas
avn has joined #ocaml
buggs is now known as buggs|afk
Guillaumito has joined #ocaml
<
Etaoin>
does anyone know how to have a method accept as an argument any subclass of the object the method is implemented on?
<
Etaoin>
or that an uncaml-like way to think?
<
mellum>
that should just work, you just have to coerce the argument, I think
<
karryall>
Etaoin: I told you, you cannot do that in general
<
karryall>
what you can do is have your method accept a subtype of some object as argument
<
karryall>
but that makes it a polymorphic method
* Guillaumito
is away: prepare le kawa de l'aprem
<
Etaoin>
thanks for the help
<
Etaoin>
it still eludes me though
<
karryall>
it's the usual mantra: "subtyping != inheritance"
* Guillaumito
is back (gone 00:09:49)
Guillaumito has left #ocaml []
<
Etaoin>
well yeah, I guess I really want a subtype, not a subclass
<
karryall>
then you can do what mellum suggested, coerce the argument to the supertype before applying it
ayrnieu has quit [Read error: 110 (Connection timed out)]
<
Etaoin>
for the help
<
Etaoin>
it seems to work now
gim has joined #ocaml
ez4 has joined #ocaml
daxie has joined #ocaml
<
daxie>
is there a way to define a type as an array of e.g. 3 floats? (like float * float * float with tuples?)
<
Smerdyakov>
No. There are no fixed size arrays. Why do you want that instead of tuples?
<
daxie>
just wondering
<
daxie>
and i'm a total n00b :p
<
daxie>
well i can write something in ocaml, but still haven't really adapted to the functional programming thing...
<
Smerdyakov>
A tuple is really like an immutable fixed size array.
<
mellum>
I wouldn't say so, since indexing by an integer is about the most common operation on arrays, and tuples don't have that
<
daxie>
well but say you need a vector (x, y, z)
<
Smerdyakov>
mellum, but there is a corresponding operation for each indexing.
<
daxie>
(or [|x;y;z|], whatever)
<
Smerdyakov>
mellum, and it's compiled just like an array access, without a bounds check.
<
mellum>
Smerdyakov: corresponding operation? What corresponds to a.(i)?
<
Smerdyakov>
When a has type t1 * t2, a.(0) corresponds to fst and a.(1) to snd.
<
mellum>
Okay, but nothing corresponds to a.(i) :)
<
Smerdyakov>
Untrue.
<
Smerdyakov>
(function 0 -> fst | 1 -> snd | _ -> failwith "Go away")
<
mellum>
Well, that's a kludge. You'd need that for every different tuple. And it's inefficient.
<
Smerdyakov>
Leaving out the issue of needing to code a version for each tuple type, it's as efficient as using an array, I'd bet.
<
mellum>
It's not, I just tried :)
<
mellum>
but admittedly, it could be optimized to be as efficient
<
Smerdyakov>
It just takes a reasonable use of lookup tables.
<
Smerdyakov>
For pattern matching on integers.
<
mellum>
Yes, but current ocamlopt doesn't do that
<
mellum>
It creates a jump table
<
mellum>
which is an order of magnitude slower
<
mellum>
but actually, if you're looking for a three-element vector, you probably don't need a.(i) anyway, but always have constant i
<
karryall>
there's records too
<
karryall>
a.x, a.y, a.z instead of a.(0), a.(1), etc
<
karryall>
it's shorter !
maihem has joined #ocaml
avn has quit [Ping timeout: 14400 seconds]
karryall has quit ["home"]
The-Fixer has quit ["Goodbye"]
The-Fixer has joined #ocaml
avn has joined #ocaml
ayrnieu has joined #ocaml
owll has joined #ocaml
noss has joined #ocaml
owll has left #ocaml []
ayrnieu has quit [Read error: 110 (Connection timed out)]
<
daxie>
are there any ocaml style guides out there?
<
Maddas>
yes, I found one with google oce
<
Maddas>
just the guide fo a university course IIRC :)
<
daxie>
but you don't have the url anymore?
<
Maddas>
once, even
<
daxie>
like is there a common naming sceme?
<
mellum>
variables start lower case, and constructors upper case :)
<
daxie>
soVariablesInMixedCase hmm
<
daxie>
and how about type/class names?
<
mellum>
I think more people use this_style
<
daxie>
oh whatever i'll use whatever i want to :p
<
mellum>
fits better with the standard library...
<
daxie>
how can i add an element to a list without return the list?
<
mellum>
You can't.
karryall has joined #ocaml
<
vect>
mellum, and what about using references /
<
daxie>
hmm is there a way to represent infinite as a float?
<
mellum>
float_of_string "inf"
<
Riastradh>
vect, that's just wrapping a reference around adding an element to the list and returning it.
<
mellum>
Probably even a better way...
<
daxie>
hmm float_of_string fails when i pass it "inf"
<
mellum>
Works for me[tm]
<
daxie>
Exception: Failure "float_of_string".
<
mellum>
There's probably a constant in the standard library somewhere
<
daxie>
but where? o_O
<
vect>
Riastradh yeah, I misanderstood the question.
<
karryall>
daxie: infinity
<
karryall>
and neg_infinity
<
daxie>
oh the obvious :p
<
karryall>
float_of_string "inf" may work, it depends on thelibc I think
<
daxie>
infinity works, that's good enough for me :)
<
daxie>
i'm really starting to like ocaml for some reason heh
ayrnieu has joined #ocaml
karryall has quit [zelazny.freenode.net irc.freenode.net]
simon- has quit [zelazny.freenode.net irc.freenode.net]
karryall has joined #ocaml
simon- has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
karryall has quit [zelazny.freenode.net irc.freenode.net]
simon- has quit [zelazny.freenode.net irc.freenode.net]
karryall has joined #ocaml
simon- has joined #ocaml
maihem has quit ["Client exiting"]