flux__ changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
smimou has quit ["bli"]
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- IRC has never been so good"]
Banana has quit [Read error: 110 (Connection timed out)]
khaladan has quit [Read error: 104 (Connection reset by peer)]
<Lob-Sogular> Don't suppose anyone here has experience with CamlGI? specifically, references to: new cgi r (where r is of Request.t), but no references how to obtain said Request.t value--so how do I do that?
<Lob-Sogular> ah. nevermind. found the examples directory in the cvs repository
Demitar has quit ["Ex-Chat"]
cyyoung has joined #ocaml
Razor-X has quit [Read error: 110 (Connection timed out)]
TaXules has joined #ocaml
bohanlon has quit [""Time to upgrade the OS""]
mikeX has quit ["zz"]
cyyoung has quit ["Leaving"]
hikozaemon has joined #ocaml
chessguy has joined #ocaml
dark_light has quit [Read error: 113 (No route to host)]
jcreigh has joined #ocaml
pango has quit [Read error: 60 (Operation timed out)]
Smerdyakov has quit ["Leaving"]
pango has joined #ocaml
jcreigh has quit ["Do androids dream of electric sheep?"]
Skal has joined #ocaml
chessguy has quit [" HydraIRC -> http://www.hydrairc.com <- Try something fresh"]
dark_light has joined #ocaml
ski_ has joined #ocaml
ski has quit [Nick collision from services.]
ski_ is now known as ski
khaladan has joined #ocaml
khaladan_ has joined #ocaml
khaladan has quit [Read error: 110 (Connection timed out)]
juhe has joined #ocaml
love-pingoo has joined #ocaml
Submarine_ has joined #ocaml
sieni_ has joined #ocaml
andreas__ has joined #ocaml
Submarine_ has quit [Read error: 113 (No route to host)]
Banana has joined #ocaml
pango is now known as pangoafk
pangoafk is now known as pango
dark_light has quit [Remote closed the connection]
Snark has joined #ocaml
Revision17 has joined #ocaml
Bigb[a]ng has quit [Remote closed the connection]
revision17_ has quit [Read error: 110 (Connection timed out)]
sidewinder has quit [Read error: 110 (Connection timed out)]
andreas__ has quit []
hikozaemon has quit ["Leaving..."]
andreas__ has joined #ocaml
andreas__ has quit [Client Quit]
PierreTramo has joined #ocaml
Skal has quit [Remote closed the connection]
lde has joined #ocaml
mikeX has joined #ocaml
_JusSx_ has joined #ocaml
PierreTramo is now known as GCarrier
mikeX has quit ["reboot"]
_JusSx_ has quit ["leaving"]
mikeX has joined #ocaml
cyyoung has joined #ocaml
rillig has joined #ocaml
lde has quit [Remote closed the connection]
multani has joined #ocaml
GCarrier has quit [Read error: 110 (Connection timed out)]
cyyoung has quit ["This computer has gone to sleep"]
cyyoung has joined #ocaml
cyyoung has quit [Client Quit]
ramkrsna has quit [Connection timed out]
ramkrsna has joined #ocaml
cyyoung has joined #ocaml
<multani> hello
<love-pingoo> hi
<multani> i have a small problem with inheritance and polymorphism, and i'm seeking some advice :)
<love-pingoo> nice, I like OO problems
<multani> great :)
<multani> i made a small example of the problem here : http://pastebin.com/709317
<multani> oops, http://pastebin.com/709318 is better
<multani> the problem is : i wanted to use the *_dumpable objects, with the dump method
<pango> (tip: pastebin.be has ocaml syntax highlighting ;) )
<multani> but since my polygon class use non-dumpable point object, it seems I can't use someting like the point_dumpable's dump method
<multani> pango, shame on me, I thought it doesn't have it :(
<pango> oh .com does too... ocaml is becoming famous or something ? ;)
<dylan> multani: you don't need inheritence in this case.
<love-pingoo> multani: why don't you require point_list points to be dumpable points in the definition of polygon ?
<multani> well I can't touch the first two classes (point and polygon)
<dylan> multani: I mean, there's no need for the dumpable class.
<love-pingoo> multani: I was about to propose you to parametrize the polygon class by the point type, to make it easy to get dumpable and non-dumpable polygons
<love-pingoo> but if you can't touch it :(
<multani> dylan, I came there a few weeks ago, with another problem of the same kind, and someone there help me, and finally, we've got this dumpable class
<multani> (if I am correct, it was ketty )
<dylan> humm. you're not even inheriting from dumpable.
<multani> dylan, the first pastebin was wrong, i corrected it in http://pastebin.com/709318 ;)
<multani> anyway, with or without this inheritance, i got the same problem
<dylan> I think it's because the polygon's point list is of type point, not point_dumpable.
<dylan> you'd need an up cast, which isn't possible...
<dylan> it's because of:
<dylan> val mutable point_list : point list = []
<dylan> and you said you can't change that?
<multani> dylan, not really
<love-pingoo> you can either redefine polygon from scratch (at least by making it parametric) or not call point#dump on non-dumpable points (dump them by yourself from the polygon's #dump)
<multani> love-pingoo, currently i do the second solution, but it's not very pretty
<dylan> a functor over polygon would be cool.
sieni_ is now known as sieni
* multani is looking for functor in the ocaml documentation ...
<ketty> multani: it would be easy if polygon_dumpable could only store point_dumpable... would that be acceptable?
<multani> ketty, as far as I know, it would be OK
<ketty> then you can rewrite "class polygon =" to "class 'a polygon ="
<ketty> and do some other changes :)
<multani> yes, but I can't touch the polygon class :'(
<ketty> ehh.. sorry, wrong syntax :/
<ketty> ohh.. bad :(
<ketty> is it very necesary that polygon_dumbable really inherits from polygon? :)
<love-pingoo> here's how to make polygon paramatric, without any functor
<love-pingoo> but you need to edit polygon
<love-pingoo> that's unavoidable
<ketty> if you really can't edit polygon.. then you have to wrap it..
<ketty> so polygon_dumpable wont _be_ a polygon, but _contain_ a polygon...
<ketty> and i think same goes for point :(
<multani> love-pingoo, got it, but I can't touch it :/
<ketty> multani: it sucks that you can't touch it :)
<multani> if I can, it would not have been as fun ;)
<multani> *if i could
<ketty> well, since you can't touch it, your code should be as loosely coupled as posible with it...
<ketty> i.e "NO inheritance" =)
<ketty> or something like that :)
<ketty> just wrap up everything that you can't touch in an interface that you can touch...
Snark has quit ["Leaving"]
<multani> hum, in any case, i don't have many solutions :(
<multani> wrapping the polygon into poly_dump is not evry good too, since polygon has many methods
<ketty> ohh...
<ketty> but that should not matter :)
<multani> and how will it solves the problem ? the point_dumpable will always be into the wrapped polygon, isn't it ?
<ketty> by wrapping i mean something like:
<ketty> < polygon: polygon; .... >
<ketty> so polygon_dumpable has a method to access the underlying polygon...
<multani> ok, but i don't see how it will solves my problem :)
<ketty> hmm.. will all polygons you use be dumpable? or will you use non dumpable polygons too?
<multani> the application will only use dumpable polygons
<ketty> than it should not be _too_ messy :)
<ketty> first step is that polygon_dumpable should _not_ inherit from polygon..
<ketty> (maybe it should not be called polygon_dumpable since it is the only polygon)
<ketty> (so, maybe call the invariant polygon Lib.polygon or Invariant.polygon or something like that)
<ketty> (and call polygon_dumpable just "polygon")
<multani> this part should not be too difficult :)
chimikal has quit [Read error: 110 (Connection timed out)]
chimikal has joined #ocaml
juhe has quit ["Leaving"]
<multani> ketty, still here ? :p
khaladan_ has quit [Read error: 104 (Connection reset by peer)]
<ketty> multani: mmm...
love-pingoo has quit ["Leaving"]
<mikeX> is there a way to export variables from a an .mly file to the corresponding .mli?
<ketty> multani: sorry, i will be out for a couple of hours now :)
<multani> ketty, no problems ;)
Smerdyakov has joined #ocaml
smimou has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
Snark has joined #ocaml
multani has quit ["Leaving"]
ski has quit [Read error: 110 (Connection timed out)]
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
ski has joined #ocaml
_exsisonek has joined #ocaml
Demitar has joined #ocaml
cyyoung has quit [Read error: 110 (Connection timed out)]
_exsisonek has quit ["Leaving"]
multani has joined #ocaml
danly has quit [Read error: 104 (Connection reset by peer)]
danly has joined #ocaml
Schmurtz has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
pango is now known as pangoafk
love-pingoo has joined #ocaml
Smerdyakov has joined #ocaml
pangoafk is now known as pango
chessguy has joined #ocaml
ski has quit [Read error: 110 (Connection timed out)]
ski has joined #ocaml
sidewinder has joined #ocaml
Snark has quit ["Leaving"]
finelemon has joined #ocaml
finelemo2 has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
finelemon has quit [Success]
Skal has joined #ocaml
Smerdyakov has quit ["Leaving"]
romildo has joined #ocaml
<romildo> Hi.
<romildo> A quick question: how to use an operator function, like the function <, as an expression?
<pango> # ( < ) ;;
<pango> - : 'a -> 'a -> bool = <fun>
<pango> is that what you mean ?
<romildo> pango: yes, thanks.
<romildo> but just found that what I really want is compare, to be used in a call to Array.sort.
cyyoung has joined #ocaml
<romildo> Is there in the library a function similar to this one: fun Some x -> x ? If so, under which name?
<pango> and what happens if it gets None as argument ?
<romildo> an exception; my definition is incomplete :(
chessguy has quit [" Try HydraIRC -> http://www.hydrairc.com <-"]
<pango> well, ocaml has no such function in its standard library, contrary to sml
<pango> it's not that hard to write, howevr
<romildo> yes. I can write it. Just wanted to know if it is already on the library. Thanks.
<pango> I don't like it much. The benefit of handling option types explicitly is that you cannot forget about the two cases ;)
<pango> if your functions really assume the value is Some _, deconstruct that value earlier and pass the deconstructed value around...
_JusSx_ has joined #ocaml
<romildo> In the algorithm I am implementing I need to find the index of an element in an array. So I wrote an auxiliary function (array_find : 'a array -> int option). But it is known that the element is on the array for sure. So I want to directly get the index i returned as the option (Some i). If there were a function the code could be cleaner (I think).
<romildo> I have written my code as follows:
<romildo> let pos_a = Array.map (fun i -> let Some j = array_find a b.(i) in j) pos_b in
<pango> you'll still probably need some None -> assert false case to avoid compiler warning
<romildo> With such a function is used, the code would be something arguably more readable like:
<romildo> let pos_a = Array.map (fun i -> maybe (array_find a b.(i))) pos_b in
<romildo> If I am not wrong, such function is called maybe in Haskell.
<pango> in SML I suppose it's Option.valOf... http://www.smlnj.org/doc/basis/pages/option.html
<romildo> Exactly.
Skal has quit [Remote closed the connection]
love-pingoo has quit ["Connection reset by by pear"]
<ketty> romildo: well.. if you want a function called maybe why not just write it?
<ketty> it is just a one liner :)
<romildo> I've done:
<romildo> exception Option
<romildo> let val_of opt =
<romildo> match opt with
<romildo> | Some x -> x
<romildo> | None -> raise Option
<ketty> let val_of = function None -> assert false | Some v -> v
<ketty> :)
<romildo> Shorter. I have not used assert before.
<ketty> you can also do: failwith "Option"
<ketty> instead of assert false
<ketty> assert is very usefull by the way..
<ketty> if haven't used it before you should start now ^^
<ketty> you do: assert (some test that you are positive should allways be true)
<ketty> and if it is not true your code will crash with an error
<ketty> so you know that your assumption was wrong..
<ketty> that helps _a lot_ in finding bugs...
<romildo> And what is the advantage to raising a specific exception (raise Option)?
<ketty> compared to failwith "Option"... i don't know :)
<ketty> might help in matching expeptions..
<ketty> if you have MyException of string
<romildo> It seems that it is the location on source code the exception is raised: exception Assert_failure of (string * int * int)
<ketty> yes
<romildo> file name, line, column
<ketty> that is very usefull to :)
<romildo> failwith "Option" raises the exception (Failure "Option"). In this case using an specific exception (raise Option) has the same effect.
<ketty> i guess the advantage of specific exception is that they can have attached data...
<ketty> so in this case it does not matter since we have no data to attach.. ^^
<romildo> it makes sense.
_JusSx_ has quit ["leaving"]
Revision17 has quit [Remote closed the connection]
romildo has quit ["leaving"]
smimou has quit ["bli"]
rillig has quit ["Changing server"]
rillig has joined #ocaml
rillig has quit [Client Quit]
Revision17 has joined #ocaml
dark_light has joined #ocaml
khaladan has joined #ocaml