mbishop__ has quit [Read error: Connection reset by peer]
travisbrady has quit [Quit: travisbrady]
mbishop__ has joined #ocaml
EvanR has joined #ocaml
<EvanR>
according to this ocaml for java programmers tutorial + +. * *. cant be overloaded. they are only for ints and floats respectively. so that makes them monomorphic functions. is there *any* way in ocaml to define + and * for other types like complex?
fschwidom has quit [Read error: Connection reset by peer]
<olegfink>
EvanR: this doesn't have anything to do with ( + ) and ( * ) specifically
<EvanR>
not those characters, no
<olegfink>
overloading is not the same as parametric polymorphism; you can easily have the latter in ocaml, but not the former
<EvanR>
so no adhoc polymorphism
<Associat0r>
you should check out delimited operator overloading
<olegfink>
yes, there are hacks that would allow you to use those characters for more than a single type, but yes, ocaml doesn't support ad hoc polymorphism
<EvanR>
whats the idiomatic way to have some other numeric type thats not int or float
<olegfink>
you may want to look at stdlib modules like Int32 and friends, and if you're speaking about overloading arithmetic functions, Associat0r's suggestion will help
<EvanR>
no just, how to write a complex addition
<EvanR>
complex_add a b
<olegfink>
I'm not really sure I understand what you're asking; again you may use Complex module as a reference
<EvanR>
i see functions add and mul for Int32
<EvanR>
same for Complex
<EvanR>
ok, so we save our sanity with a module system
<olegfink>
in the standard library, the naming of those functions is just a convention; it is somewhat enforced by pa_do
<olegfink>
I don't think ocaml has a single-precision floating point type
<EvanR>
hold the phone, i just discovered (<) : 'a -> 'a -> bool, i can see its parametrically polymorphic, but how does it manage to work without knowing its input types?
<EvanR>
it doesnt work on just int and float
<olegfink>
(<) is magic.
<EvanR>
is this some of that < overloading thing Associat0r was talking about
bacam has quit [Ping timeout: 248 seconds]
bacam has joined #ocaml
<olegfink>
no, this is a built-in ordering that is defined in the usual way for usual types and then extended to all types
<EvanR>
sort of like ad hoc polymorphism
<EvanR>
in disguise
<olegfink>
it is not a language feature, you can't (easily) define your own (<)
<EvanR>
ok
Edward__ has quit []
<EvanR>
it says that (==) : 'a -> 'a -> bool has an implementation dependent result when applied to 'non mutable' structures
<EvanR>
what does that mean in practice
<olegfink>
that two structures that are (=) may be (!=)
<olegfink>
if you know java or some such, (=) vs. (==) is like .equals() vs. ==
<olegfink>
if String s1.equals(String s2), it doesn't imply s1==s2
Associat0r has quit [Quit: Associat0r]
<EvanR>
k i dont really know java
<EvanR>
physical equality
<EvanR>
i get it
<EvanR>
so for non mutable structures i should just use =
<EvanR>
because == is defined in terms of mutation
<olegfink>
you should almost always use =
<EvanR>
ok
<EvanR>
does ocaml have subtype polymorphism
_unK has quit [Remote host closed the connection]
sshc has joined #ocaml
sshc has quit [Read error: Connection reset by peer]
sshc has joined #ocaml
jeddhaberstro has joined #ocaml
elehack has joined #ocaml
<elehack>
thelema, thanks for the 1.2.2 release. it works & has been pushed to GODI.
seanmcl has quit [Quit: seanmcl]
_JFT_ has quit [Quit: _JFT_]
bacam has quit [Read error: Operation timed out]
bacam has joined #ocaml
pad has quit [Remote host closed the connection]
elehack has quit [Quit: Goodbye...]
jonafan_ has joined #ocaml
mbac has joined #ocaml
jonafan has quit [Ping timeout: 264 seconds]
mbishop__ has quit [Ping timeout: 265 seconds]
valross has quit [Ping timeout: 260 seconds]
thrasibule has joined #ocaml
valross has joined #ocaml
emmanuelux has quit [Remote host closed the connection]
mbishop has joined #ocaml
psnively has joined #ocaml
ulfdoz has joined #ocaml
<thelema>
EvanR: (<) works on the runtime representations of the given two values.