jemfinch` changed the topic of #ocaml to: nob: it's not an option keyword. It's a datatype. 'a option. It can be either "None" or "Some data" -- it represents either data that's not there (None) or data that's there (Some data)
scott has joined #ocaml
Etaoin has joined #ocaml
<Etaoin>
hi
<scott>
hi
<malc>
gee what a contentful conversation
<scott>
in ocmal how do you make a class method?
<scott>
as opposed to an instance method
<malc>
scott: insert it before object
<malc>
class foo = let moo = .. object
<Etaoin>
I'm content.
<scott>
and are there single line comment characters?
<scott>
like as apposed to (* *)
<malc>
no
<malc>
you can simplify your life with a simple macro if you use emacs though
<scott>
what about the concatenate operator/function for strings?
<malc>
^
<scott>
oh yeah, I remember reading that
<scott>
is there 1) no file stream? 2) no find tokens method for strings?
<malc>
no file stream? in what sense
<scott>
I was asking if it's wrong to conclude there is no file streams in ocaml
<scott>
such a stream would hook up to a file and you would set a delimiter cahracter and you could say next(filestream) and get the next segment from the file up to the delimeter
<malc>
no there is no such thing in standard/core library
<scott>
what about tokenizer for strings?
<malc>
no
malc has quit ["no reason"]
Etaoin has quit ["raise OverFlowError, "Ewwww, now it's all over the floor.""]
graydon has joined #ocaml
proff has quit [carter.openprojects.net irc.openprojects.net]
proff has joined #ocaml
graydon has quit [Remote closed the connection]
__DL__ has joined #ocaml
Yurik has joined #ocaml
malc has joined #ocaml
__DL__ has quit [Read error: 110 (Connection timed out)]
owll has joined #ocaml
graydon has joined #ocaml
malc has quit ["no reason"]
MegaWatS has joined #ocaml
<MegaWatS>
hi :>
<MegaWatS>
anybody there? :|
<MegaWatS>
=8[
<smkl>
...
<MegaWatS>
what "..." ? :<
<Taaus>
...
<MegaWatS>
hm
<MegaWatS>
ah well anyway
<MegaWatS>
i have a question if anyone feels like helping me :|
<Taaus>
Well, I do, I guess ;)
<MegaWatS>
:]
<MegaWatS>
well at least
<MegaWatS>
i was already starting to be concerned
<MegaWatS>
what with the cold reception i got :|
<Taaus>
lol
<MegaWatS>
:p
<MegaWatS>
so youre knowledgeable about the optional parameters?
<Taaus>
Not at all :)
<MegaWatS>
:[
Yurik has quit [Remote closed the connection]
<MegaWatS>
hm well then i dont suppose you could answer my question:
<MegaWatS>
i was experimenting a bit with those labels and optional arguments earlier ...
<MegaWatS>
and i thought of something i felt was a neat idea but it didnt work like i expected it to :/
<MegaWatS>
i thought the optional parameters might be a good way to do something like
<MegaWatS>
for example a function that does some computation or the like
<MegaWatS>
but it might work on real numbers (ie floats), complex numbers, ratios or ints etc
<MegaWatS>
and it is supplied with the functions for the basic ooperationas
<MegaWatS>
ie
<MegaWatS>
something like
<MegaWatS>
let compute_f mult add x = mult (add (mult x x) x) <- just as an example
<Taaus>
Look at how nums are defined...
<MegaWatS>
?
<Taaus>
Module Nums.
<MegaWatS>
hm
<Taaus>
Or, Num, rather.,
<Taaus>
I think.
<smkl>
if the optional parameters have some types, they cannot become more general
<MegaWatS>
i know it is a variant type
<MegaWatS>
yes
<MegaWatS>
thats exactly the problem i encountered and i didnt expect :)
<Taaus>
smkl: How about making it a union type of int | float | etc. :)
<MegaWatS>
from my naive point of view it looked like a neat way to simulate something like overloading
<Taaus>
That's how the Num thingy works.
<MegaWatS>
yes of course that works but its limited
<MegaWatS>
because it only takes into account the types that you already took into account when defining the union
<Taaus>
type num =
<Taaus>
| Int of int
<Taaus>
| Big_int of Big_int.big_int
<Taaus>
| Ratio of Ratio.ratio
<Taaus>
Obviously.
<MegaWatS>
the other way is via modules
<MegaWatS>
ie
<Taaus>
It wouldn't be safe otherwise, I guess :)
<MegaWatS>
well i expected it to be able to do somethign likme
<MegaWatS>
let compute_f ?(mult = ( *. )) ?(add = ( +. )) x = mult (add (mult x x) x)
<MegaWatS>
and then come out with a type like, say,
<MegaWatS>
compute_f : ?mult:('a -> 'a -> 'a) -> ?add:('a -> 'a -> 'a) -> 'a -> 'a
<MegaWatS>
i guess the default values for the parameters 'lock in' the type of that argument
<MegaWatS>
and it cant be generalized anymore to more general types
<MegaWatS>
but i wondered why that is so ...
<MegaWatS>
is it by design? or is it not possible to do this? ie would the typechecking become too complex/undecidable if one did this, like it apparently does with overloading?
<smkl>
well, if the type would be ?mult:('a -> 'a -> 'a) -> ?add:('a -> 'a -> 'a) -> 'a -> 'a, then compute_f "asd" would be valid
<smkl>
but perhaps there could be some more complex type system ...
<MegaWatS>
hmm
<MegaWatS>
the way I see it
<MegaWatS>
compute_f "asd" would NOT be valid because
<MegaWatS>
compute_f "asd" would, in this context,
<MegaWatS>
compute_f have type float -> float
<MegaWatS>
like it does
<MegaWatS>
now
<smkl>
compute_f and compute_f ~add ~mult would have to have different types
<MegaWatS>
yes
<MegaWatS>
but wheres the problem with that?
<MegaWatS>
i mean
<MegaWatS>
map (( +) 1) and map (( ^ ) "x")
<MegaWatS>
have different types, too...
<MegaWatS>
ie
<MegaWatS>
several arguments of map share a single type parameter
<smkl>
the function map has same type in both expressions
<Taaus>
Different types? They both have type 'a
<MegaWatS>
hmm
<MegaWatS>
yes
<MegaWatS>
but compute_f
<MegaWatS>
is just an abbreviation i thought :/
<MegaWatS>
for compute_f ~mult:( *. ) ~add:( +. )
<MegaWatS>
so
<MegaWatS>
like map ( ( + ) 1)
<MegaWatS>
while map is ('a -> 'b) -> 'a list -> 'b list
<MegaWatS>
map (( + ) 1) is int list -> int list ...
<MegaWatS>
wouldnt this be possible?
<MegaWatS>
ie compute_f has, in this form, type float -> float, because its parameters - mult and add - are given as float -> float, thus filling the type parameter 'a in with float
<MegaWatS>
but if i explicitly override them, with eg int -> int functions, the type parameter 'a gets filled in with int instead ...
<smkl>
compute_f is not an abbrevation for compute_f ~mult:( *. ) ~add:( +. ) ... f ~x ~x is different from f ~x
<MegaWatS>
hmm
<smkl>
it might be possible to find better semantics for labels, though
<MegaWatS>
well maybe
<smkl>
anyways, it's possible to have parameterized sets of functions using functors
<MegaWatS>
i just thought it might be a neat way to emulate overloading without the need for functors in such simple cases ...
<MegaWatS>
hmm
<smkl>
yes it seems intuitive but it's not clear how to implement that
<MegaWatS>
well thanks anyways ill guess ill just have to live with it :)
<smkl>
you could also try searching the mailing list and if you don't find anything, send a message about it
<MegaWatS>
which mailing list? :)
<smkl>
caml mailing list
<MegaWatS>
hmm yes i supposed something like that but ... you mean the thing in the fa.caml link on www.ocaml.org ?
<MegaWatS>
or something else?
<MegaWatS>
ah i see it now
<MegaWatS>
on caml.inria.fr ...
funroll-loops has joined #ocaml
<MegaWatS>
theres even a searchable index :\
* funroll-loops
waves.
<MegaWatS>
hi
<funroll-loops>
Hi. I know nothing about Ocaml. I'm just here to lurk. :)
<MegaWatS>
:p
<funroll-loops>
Okay -- I do have a question: Is it pronounced "ahk'-am-el"? "o-cam'-el"?
<Taaus>
Oh Camel, I'd say ;)
<Taaus>
There's usually an apostrophe between O and Caml :)
<Taaus>
(Well, except on this channel, that is ;)
<smkl>
hmm, it'd be possible to have #o'caml as a channel name
<Taaus>
Yeah, but it wouldn't be very user friendly ;)
<smkl>
hmm, in the manual, they use "OCaml", "O'Caml" and "Ocaml". "O'Caml" and "Ocaml" are only used once
<Taaus>
Well, I'd say Objective Caml -> O'Caml makes sense (There's an O'Haskell as well, though I'm not sure I'm helping my case by saying that ;)