systems has joined #ocaml
systems has quit [Client Quit]
rhil is now known as brwill
adam has joined #ocaml
<adam> What is the proper way to create mutually recursive functions local to a class object definition?
<Riastradh> Er, what do you mean 'local to a class object definition?'
<phubuh> i'd like to know the proper way to create mutually recursive functions in general
<Riastradh> let rec foo x y z = do stuff
<Riastradh> and rec bar x y z = do more stuff
<Riastradh> ...I think.
<phubuh> oh, i was under the impression that "and rec" wasn't valid
<Riastradh> Maybe there's no second 'rec.'
<Riastradh> Yeah, no second 'rec.'
<phubuh> ah, okay. thanks!
<phubuh> by the way, is it possible to have to modules that depend on each other?
<phubuh> s/to m/two m/
<Riastradh> I don't know.
adam has quit ["thanks"]
<teratorn> any of yall use C much? any recommendations for a high-level string library?
<teratorn> please don't ask why i'm using C right now, believe me, i wouldn't if i could help it :)
<Riastradh> Why are you using C?
* teratorn kills Riastradh
<Smerdyakov> Everyone check out Blast at http://www-cad.eecs.berkeley.edu/~rupak/blast/ !
<Smerdyakov> It's a model checker for C programs, written in OCaml.
<Zadeh> cooool!
<Smerdyakov> It works really well. Uses theorem provers.
<Zadeh> there goes another one of my ideas
foxster has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
Zadeh has quit [Read error: 54 (Connection reset by peer)]
gene9 has joined #ocaml
foxster has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
CybeRDukE has joined #ocaml
brwill is now known as rhil|zzz
rhil|zzz is now known as brwill|zzz
CybeRDukE has quit ["Real_men_don't_need_spacebars."]
Smerdyakov has quit [Read error: 60 (Operation timed out)]
lus|wazs has joined #ocaml
gene9 has quit []
Smerdyakov has joined #ocaml
Smerdyakov has quit [Read error: 60 (Operation timed out)]
noss has joined #ocaml
phubuh has quit ["Client exiting"]
noss has left #ocaml []
Smerdyakov has joined #ocaml
Smerdyakov has quit [Read error: 110 (Connection timed out)]
Smerdyakov has joined #ocaml
owll has joined #ocaml
docelic has joined #ocaml
Smerdyakov has quit ["kvm switch experiments"]
docelic has quit ["later"]
Smerdyakov has joined #ocaml
Tov has joined #ocaml
<Tov> hi
<Riastradh> Hi.
det has joined #ocaml
<det> join #twisted
<det> oops
<det> Can nayone point me to any kind of information on how functors are implemented in ocaml ?
<det> or first hand knowledge? :)
<Riastradh> Use the source, Luke!
<det> that doesnt sound very fun
<det> someone made me believe ocaml was all funa nd games
<Riastradh> If OCaml is fun and games, reading OCaml source should be fun.
<det> fun is only had on the torment of others!
<det> xavier torments so we can have eternal life^W^Wfun
owll has quit ["Client Exiting"]
owll has joined #ocaml
<det> so after some relunctance I am discovering ocaml is the coolest language ever
<det> why is nobody using it ?
<teratorn> some people use it
<teratorn> i would use it more if it had a wicked python interface :)
<det> there is pyocaml
<teratorn> eh
<teratorn> pycaml you mean :)
<det> maybe that doesnt qualify as wicked, i know nothign about it :)
<det> yes
<det> that I guess
<det> why bother with python when you have ocaml
<teratorn> uhm
<teratorn> it's more productive, i suppose :)
<teratorn> anyway
<teratorn> pycaml appears to only allow embedding
<teratorn> which is pretty sucky
<det> maybe i do know something about pycaml
<det> I vaguely remember it being both ways
<det> python in ocaml or ocaml in python
<teratorn> they/he explicitly mention the embedding ablity but not extending
<det> It is intended to allow users to build native ocaml libraries and use them from python, and alternately, in order to allow ocaml users to benefit from linkable libraries provided for python.
<teratorn> oh wait, your right
<teratorn> yeah i just saw that
<det> but it seems mostly geared towards using ocaml within python
<teratorn> eh?
<teratorn> what makes you say that?
<det> example #2 in "why is pycaml" seems to be the most enthusiastic :)
<det> but me personally, I am learning to shun python and it's dynamicly typed evilness
<teratorn> why?
<teratorn> static typing is good if you want higher performance code
<teratorn> otherwise, it's just more work
<det> nahh
<det> runtime errors are more work
<teratorn> i've never had a problem where staic typing woudln't helped
<teratorn> i mean
<teratorn> s/wouldn't/would've
<det> you've never hada value in python being passed around that was None and shouldnt have been
* teratorn thinks
<det> maybe being assigned to a value that None meant something else
<det> etc..
<teratorn> oh yeah, that happened once.
<teratorn> it was trivial to fix
<det> how is static typing more work when you have type inference ?
<det> give an example :)
<teratorn> your stuck with one type
<teratorn> how can you pass interface-compatible objects around freely?
<det> well
<det> that was my main concern with ocaml
<det> here was my solution
<det> showable.ml:
<det> type showable = {
<det> show: unit -> unit;
<det> }
<det> let create s show = {
<det> show = fun () -> show s
<det> }
<det> let show s = s.show ()
<det> circle.ml:
<det> type circle = {radius: float}
<det> let create r = {radius=r}
<det> let show c = Printf.printf "Circle, radius: %f" c.radius
<det> let as_showable c = Showable.create c show
<det> main.ml:
<det> let c = Circle.create 10.0
<det> let s = Circle.as_showable c
<det> let _ = Showable.show s
<teratorn> and you don't see my point?
<teratorn> :)
<det> I agree there needs to be syntactic support for waht i just did
<det> but it's not really complicated at all :)
<teratorn> hang on, let me try to understand that
<teratorn> i'm pretty new with ocaml
<det> basicly I have a type "showable" that is a record of whatever functions are in the interface with the specific type partially applied out
<teratorn> eh well that's greek to me, but lets move on :)
<det> note: I had to do fun () instead of partially applying the argument because ocaml is a strict language :)
<det> well
<det> let my try to whip up a python example
<det> of the same thing
<teratorn> eh, why?
<det> erm, nm then :p
<det> was trying to explain
<teratorn> i'll figure it out, if i need to
<det> think of it like this
<teratorn> so, how about python stdlib and 3rd party modules vs ocaml's? :)
<det> lets say you have a function called draw
<det> that takes an object to draw and a size
<det> so you have all kinds of objects that support this draw interface
<teratorn> yeah
<det> maybe to draw a circle is like this: let show size = Printf.printf "I'm drawing a size %d circle!" size
<det> erm
<det> maybe to draw a circle is like this: let draw_circle size = Printf.printf "I'm drawing a size %d circle!" size
<det> erm
<det> wron again :)
<det> maybe to draw a circle is like this: let draw_circle circle size = Printf.printf "I'm drawing a size %d circle with a radius of %f" size circle.radius
<det> ok ignore the last 2 lines
<det> understand that ?
<det> so far
teratorn_ has joined #ocaml
<teratorn_> :/
<det> oh
<teratorn_> what did i miss?
<det> maybe to draw a circle is like this: let draw_circle circle size = Printf.printf "I'm drawing a size %d circle with a radius of %f" size circle.radius
<det> draw_circle would have type: fun circle -> int -> unit
<det> understand that ?
<teratorn_> sure
<det> well now we want to store a list of objects that support the "draw interface"
<det> if we have a circle called some_circle and we do: let drawable = draw_circle some_circle
<det> the value drawable has the type int -> unit
<det> got me so far ?
* teratorn_ thinks
<det> it is just applying the first argument of draw_circle, leaving the other argument unapplied
<teratorn_> ah yes
<teratorn_> right right, returning a curry?
<det> yes
<det> its like
<det> it's like: let drawable = fun size -> draw_circle some_circle size
<det> behaves the same
<teratorn_> ok
<det> but tha tis irrelevant
<det> so now we have a function that only takes an int and draws the object :)
<det> so we can store a list of these functions
<det> instead of the actual objects
<teratorn_> ok, so your assuming that you have control over all this code?
<det> nope
<det> well
<det> what do you mean by that ?
<teratorn_> i mean, what if your using a third party module
<det> you can still create the closures :)
<teratorn_> ok
<det> what I did in the above example was create a record of the type of all the interfaces with the first argument applied out and used that as the abstract type
<teratorn_> would i have to use this procedure, or something like it, every time i do a subclass and want to pass instances to functions that were designed for the original?
<det> but ocaml does have its own class system
<teratorn_> yeah it makes sense, mostly :)
<det> that you could use instead
<det> but im not a fan of it
<det> here is an example from mrvn
<det> class virtual base_drawable = object
<det> method virtual draw : unit
<det> end;;
<det> class button = object
<det> inherit base_drawable
<det> method draw = print_string "Draw button\n"
<det> end;;
<det> class icon = object
<det> inherit base_drawable
<det> method draw = print_string "Draw icon\n"
<det> end;;
<det> let l = [((new button) :> base_drawable); ((new icon) :> base_drawable)];;
<det> List.iter (fun x -> x#draw) l;;
<vegai> hm, calculating a fibonacci is quite slow with the trivial function at least
<det> teratorn, with the ocaml object system you can work very much like python or c++
<det> teratorn, I dont even think you need to inherit from the base class for it to work
<det> teratorn, sound like you would much prefer that
<det> teratorn, the object system way opposed to closures that is
<teratorn_> well i'm not sure what you mean, since python and c++ are two totally different beasts
<teratorn_> det: yeah, probably
<vegai> calculating fib 50 took 3m12s
<det> I mean, the example above, it creates a list with 2 different objects that both support the draw method
<det> vegai, is that slow compared to C you mean ?
<vegai> det: I don't know, in fact
<vegai> it seems weirdly slow for such a low figure
<det> the computer shootout calculates fib 32 in 0.18 secs
<det> erm, dougs computer language shootout
teratorn has quit [Read error: 110 (Connection timed out)]
<det> let rec fib n = if n < 2 then 1 else fib (n - 2) + fib (n - 1)
<vegai> 0.034s here
<det> using that
<vegai> yes, I used match n with, which may be slower?
<det> ok, sounds like an exponential problem to me ;)
<vegai> indeedo, it just surprises me how fast it gets very costly
<vegai> all you wise people knew this already, of course=)
<det> I dont include myself among the wise
<det> im still in the curious phase :)
<det> I should eat
<det> teratorn_, oh, and you can omit the ;;s from the end of the lines in that example, he typed it in the toplevel :)
owll has quit ["Client Exiting"]
det has quit []
teratorn_ is now known as teratorn
teratorn has quit ["Client exiting"]
docelic has joined #ocaml
<Tov> \o/ caml roxor !!
Smerdyakov has quit [Killed (NickServ (for nickname owner))]
Smerdyakov has joined #ocaml
Tov has left #ocaml []
Smerdyakov has quit ["BRB, installating stuff!"]
gl has quit [leguin.freenode.net irc.freenode.net]
mattam_ has joined #ocaml
Smerdyakov has joined #ocaml
gl has joined #ocaml
systems has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Smerdy has joined #ocaml
Smerdyakov has quit [Killed (NickServ (for nickname owner))]
Smerdy is now known as Smerdyakov
systems has left #ocaml []
Smerdyakov has quit [Read error: 54 (Connection reset by peer)]
Smerdyakov has joined #ocaml