ChanServ changed the topic of #ocaml to: http://icfpcontest.cse.ogi.edu/ -- OCaml wins | http://www.ocaml.org/ | http://caml.inria.fr/oreilly-book/ | http://icfp2002.cs.brown.edu/ | SWIG now supports OCaml
<Yurik> re
<taw> let foo x = 0 in let bar x = foo 1;;
<taw> bar is const as you can see
<mrvn> taw: yes and that would be slightly different.
<taw> mmm
<taw> oh, that won't compile
<mrvn> taw: then bae x = foo x and foo x something non const. Doesn't change the example.
<taw> let foo x = 0;; let bar x = foo 1;;
RichiH has quit [""Did you ever walk into a room and forget why you walked in? I think that is how dogs spend their lives." Sue Murph"]
<taw> anyway bar is not recursive at all
<taw> neither real recursive nor tail recursive
<mrvn> taw: Its tail recursive.
<mrvn> it calls another function without the need to ever return here.
<taw> mrvn: no it's not, it will be inlined and not called at all
<mrvn> taw: Thats just because its so simple.
<taw> hehe :)
<mrvn> taw: make it computet PI to a million digits and then call foo with that.
<taw> recursion
<taw> <mathematics, programming> When a {function} (or {procedure})
<taw> calls itself.
<mrvn> tail recursion
<mrvn> <programming> When the last thing a function (or procedure)
<mrvn> does is to call itself. Such a function is called tail
<mrvn> recursive. A function may make several recursive calls but a
<mrvn> call is only tail-recursive if the caller returns immediately
<mrvn> after it.
<mrvn> Strictly speaking yes.
<mrvn> let foo x = 1 + foo x;; recursive
<mrvn> let foo x = foo (x + 1);; tail recursive
<taw> let rec
<mrvn> aeh, +rec
<taw> difference between let and let rec is important in lambda but why the fuck did they introduced it in ocaml ?
<gl> because of the dynamic typing
<gl> s/dynamic/static
<taw> there's no problem with making everything recursive by default
<gl> oh?
<mrvn> let foo x = 0; let foo x = if x = 0 then 0 else foo (x - 1);;
<gl> let f x = 1; let f x = f 1;;
<mrvn> That compiles but because it has no rec its not what you want.
<taw> sure, that's just plain evil
<gl> let f x = f 1;; returns 1
<taw> you ought not redefine that
<taw> with rec no such problems would happen
<taw> if rec was default i mean
<mrvn> taw: let foo x = let x = x + 1 in Printf.printf "x is now %d\n" x; x
<taw> and "let norec" for really rare cases when one doesn't want that
<mrvn> taw: I see it often that variables are named the same when the intend is to change them.
<mrvn> taw: That would not work without rec.
<taw> this style is evil anyway, so should not be promoted
<mrvn> taw: I think its quite readable.
<taw> well, i can live with in but let foo x = let y = x + 1 in Printf.printf "y is now %d\n" y; x
<taw> would be better
<taw> x is no friggin variable
<taw> becoming late
* taw going to sleep now
taw has left #ocaml []
<mrvn> # let rec ackerman x y = if x > 0 then ackerman (x-1) (if y > 0 then ackerman x (y-1) else 1) else (y+1);;
<mrvn> val ackerman : int -> int -> int = <fun>
<mrvn> recursive or tail recursive?
<gl> tail recursive
<gl> mh
<mrvn> gl: why? It calls (+) last sometimes
<mrvn> From its dict entry the ackerman calls are tail recursive but the function is not.
Yurik has quit [Read error: 54 (Connection reset by peer)]
<mrvn> (i would say)
<mrvn> Its a nice function by the way. Try a few values for x and y.
<gl> for me, a tail-recursive function is only a function that return the result without "depiler" anything is the function calls' stack
<gl> the ackerman
<gl> the ackerman's complexity is awful.. worse than exponential
<mrvn> gl: It heavily uses the stack
<gl> ack 6 0 will crash the stack
<mrvn> gl: If x,y > 0 it calls A(x-1, A(x, y-1))
<mrvn> That needs stack space
<gl> i allready compute the result of ack 7 0.. with pen and paper of course
<mrvn> gl: ack 5 0 is 65533
<mrvn> gl: ack 4 0 is 13
<gl> i know
<mrvn> ack 6 0 probably overflows with 31 bit
<gl> ack 7 0 was something like pow 2 (pow 2, pow 2, pow 2, pow 2... )) 256 times
<mrvn> gl: worse
<gl> pow (2, pow(2, pow(2,..)))
<gl> perhaps i don't remember the exact result
<mrvn> Its a realy simple example function to show recursive explosion
malc has quit ["no reason"]
<mrvn> Looks realy harmless but exceeds any limits you would think of for its runtime.
<mrvn> A(4, 2) = A(3, A(4, 1)) = A(3, 65533) = 5+8*(2^65533-1)! The result is a number which consists of 19729 digits!!
<mrvn> A(6,0) exceeds 31 bit by far too.
as has joined #ocaml
as has quit [Client Quit]
jao has left #ocaml []
Yurik has joined #ocaml
inkedmn has joined #ocaml
<inkedmn> anybody here use ocaml in windows?
<inkedmn> (without cygwin)
<mrvn> Well, inside my xterm window, my xemacs window, my gtk window :)
<inkedmn> i have a windows-specific problem...
<inkedmn> i'm trying to fire up the interpreter, but i get "incorrect path for ocaml.exe"
<inkedmn> my path is set right, i can run ocaml in the console without a problem
<inkedmn> any ideas?
<mrvn> don't use windows
<inkedmn> ...
<inkedmn> thanks for the insight
inkedmn has quit [Client Quit]
gl has quit [Read error: 110 (Connection timed out)]
Torquemada has quit ["Lost terminal"]
Yurik has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
<gl> re
<whee> hola gl
<gl> my pc crashed.. after i asked him to compute ackermann 7 0 :)
<whee> heh
<whee> hmmf
<whee> is there something that'll automatically generate a makefile for ocaml programs?
<gl> whee ?
<gl> ocamldep could help you, no ?
<whee> ocamldep does the dependencies but not the rest
<gl> you knew it.. ok, so i can't help you
<whee> I guess I should learn how to make makefiles at some point. heh
<mr_bubbs> there's at least one
<whee> oh yeah
<whee> there's a few on caml humps. probably shouldve checked
<whee> hooray for pierre and his nice generic makefile
<mr_bubbs> hehe
MegaWatS has quit ["Oceania has ALWAYS been at war with Eastasia!"]
graydon has joined #ocaml
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
docelic has quit ["later all"]
<whee> hrmf
<whee> how do I move a file with the Unix module?
<whee> (move between directories)
<whee> oh nevermind, Unix.rename does work but my permissions are off
Yurik has joined #ocaml
<Yurik> re
<whee> hola
<Yurik> whee: re
<whee> almost done my program :\ working on parsing command line arguments now
<gl> pff.. 4:42 am here
<gl> whee, you too? :)
<whee> I'm doing a program that sorts files in a directory by extension, filename, access/modification/creation dates, uid/gid, size, etc
<whee> it's all done except for docs and actual interface heh
<Yurik> 5:45 here :))
<gl> i'm doing a compiler.. prescript -> postscript (prescript is a simple description language)
<whee> I've been out of ocaml programming for a while so I needed something to warmup with, this seemed easy enough
<gl> simple.. with recursivity, record types, some other structures, functions, and some other features
<whee> the Arg module needs some examples somewhere :|
<Yurik> whee: what for?
<whee> because I'm an idiot and didn't know how to use it :D
<whee> got it now though; it's really nice how it checks argument types and all for you
<Yurik> :))
<Yurik> Arg is really pretty one
<whee> it just saved me a lot of time if I had to implement that myself heh
gl has quit ["sic transit gloria mundi"]
<Yurik> :)
gl has joined #ocaml
* Yurik hasbn't seen any such kinda equiv of Arg in stdlibs of other languages
<Yurik> s/hasbn't/hasn'/
<Yurik> s/hasbn't/hasn't/
<Yurik> bah :)
<whee> heh
<whee> I'm still surprised how well this project has turned out given not much time
<whee> I wouldnt want to try writing this in c++ or java, I use hofs too much :|
<Yurik> hofs - ?
<whee> higher order functions
<whee> it's nice when lines that do so much read just like english because of them
<Yurik> ah
<Yurik> I usually write about them as HOFs, so was too stupid to not to recognize "hofs" :-)
<whee> ah
* Yurik is building new pxp
<whee> I'm having a problem deciding on a version number for this thing :\
<whee> I'm tempted to go and call it 0.01 and then have people think it must suck because it's so early :D
* Yurik should wait for 1.5h for opening the nearest shop to buy some hardsalted mineral water :(
<Yurik> for which thing?
<whee> my file organization project
<whee> thinking of putting it on freshmeat, might be useful for others
<Yurik> what your project do?
<whee> scroll up :D
<Yurik> don't see :(
<Yurik> what do you mean by file organization?
<whee> hold on
<whee> hfaha oops typo in there too
<Yurik> got an idea
<whee> speed of this surprised the hell out of me
<Yurik> ( a lot of porn there, hehe )
<whee> under a tenth of a second to sort my downloads directory, which is a gig or two
<whee> heh
<Yurik> name it 1.0 and it willn't be recognized as too early :-)
<Yurik> or at least 0.9.9 :-))
<whee> haha
<whee> I'll start with 8.3.2.1 and let the users figure out how that scheme works
<Yurik> friend of mine usually starts with 1.0 :-) may be you've heared about his works - centericq, motor, groan
<whee> nope :|
<whee> I really need to start releasing more of the things I do, the last thing I relesaed was a crappy perl script from a year ago when I was an idiot
<whee> it was a script that would let you work out perl regular expressions and see what they matched as you typed. it was pretty useful but bad coding style
<Yurik> btw, they are more or less good ones, you can get them from http://konst.org.ua/
<Yurik> perl and good coding style are incompatible :-)
<whee> heh
<Yurik> later
Yurik has quit ["÷ÙÛÅÌ ÉÚ XChat"]
<whee> erm
<whee> what do I do when two files depend on each other
<whee> I'm getting a "Reference to undefined global `Blah'" during linking because one file comes before one it depends on in the command line
<whee> but the one it depends on depends on the first file so I can't switch or I get the same thing but regarding the other one
<whee> eh oh
<whee> is this something I'm supposed to just not do
<whee> I don't know how I'm going to get around these dependencies :\
graydon has quit ["xchat exiting.."]
Yurik has joined #ocaml
<Yurik> re
<Yurik> later :)
Yurik has quit [Client Quit]
<whee> heh
mrvn_ has joined #ocaml
two-face has joined #ocaml
<two-face> hi
mrvn has quit [Read error: 110 (Connection timed out)]
zack has joined #ocaml
gl has quit [Connection timed out]
<two-face> hello zack
<zack> two-face: fi
<zack> two-face: hi
<two-face> zack: i found no way to work around no open types in methods
<zack> hi answered on the ML ...
<zack> you just have to cast down the object argument
<two-face> i'm currently reparing my MUA :p
<two-face> well, my MUA config
<two-face> fear
gl has joined #ocaml
zack is now known as foo
foo is now known as zack
<two-face> zack: are you sure about what you said?
<gl> 'lo *
<zack> almost ...
<two-face> zack: i've read in the ocaml book that open types aer not allowed as parameters
<zack> is right
<zack> you indeed use a closed type as a parameter
<zack> and restrict the argument to that closed type
<two-face> but the restriction is in the method invocation right?
<zack> in the argument you pass to the method
<zack> try this:
<zack> class arg = object method a = () end
<zack> class argson = object method a = () method b = () end
<zack> class obj = object method (arg:arg) = () end;;
<two-face> ok
<zack> wait
<zack> let o = new obj
<zack> then this wont work:
<zack> damn!
<zack> I forget the method name!
<zack> o#foo (new arg)
<zack> the above work
<zack> o#foo (new argson)
<zack> the above wont work
<zack> o#foo (new argson :> arg)
<zack> the above work again
<two-face> hmmm
<zack> just try ;)
<two-face> yes, right now
<zack> and ...?
<two-face> didn't you forget inherit ?
<zack> ok, in argson you can remove method "a" and add "inherit arg", it's the same
<zack> inheritance is syntactical in ocaml
<two-face> ah
<two-face> ok, understood
<zack> does it work?
<two-face> it does
<two-face> thanks
<two-face> zack: it means implicit downcasting
<zack> no, this is upcasting and is explicit
<zack> downcasting isn't a type safe constructor
<two-face> ah yeah, sorry, upcasting that's what i meant
<zack> ok, but is still explicit ;)
<two-face> yes
<two-face> well, doesn't matter
<zack> this is a major difference for programmers that come from the C++, Java world
<two-face> yeah
docelic has joined #ocaml
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
<two-face> zack: olivier andrieu mentioned polymorphic methods
<zack> two-face: yes, I've seen, but is a bit overkilling for your usage, IMHO
<two-face> zack: maybe
<gl> f***ing freesurf
docelic has quit ["Client Exiting"]
<pnou> overkilling?
<pnou> seems to be a great solution
<two-face> i must have a look
<zack> pnou: it depends on what you have to do with the argument object
<pnou> i don't understand
<pnou> can you give me an example?
<mrvn_> pnou: for example you have a class base that has a update function
<mrvn_> and you have a class foo that inherits base.
zack is now known as zack_gnam
<mrvn_> You can write a function that iterates over an list of base and updates each element returning an updated list.
<mrvn_> If you call that with a list of foo downcasted to base it will return a list of base. If you write a polymorphic function it can take a list of foo and return a list of foo since foo inherits base.
<pnou> yep, but two face method type is 'a . (#obj as 'a) -> unit
<two-face> i'll look into the manual
zack_gnam is now known as zack
malc has joined #ocaml
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
RichiH has joined #ocaml
<RichiH> hello again :)
<RichiH> this time i want to know how i can create a pattern matching funtion that will execute another command before actually matching any patterns
<RichiH> as 7 lines were ok yesterday, i'll paste four lines to show you what i mean
<RichiH> let f_x_2 x = match x with
<RichiH> mod_float x 1.5;
<RichiH> |x < 1.5 -> failwith "<1.5"
<RichiH> |x >= 1.5 -> failwith ">= 1.5";;
<RichiH> or would it be better to do the mod_float before starting the pattern amtching?
zack is now known as zack_shower
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
malc has quit [Read error: 110 (Connection timed out)]
RichiH has quit ["Have you ever wondered who shells all those little peanuts?"]
zack_shower is now known as zack
taw has joined #ocaml
<two-face> bye
<two-face> well, bbl
two-face has quit ["Client Exiting"]
zack has quit ["Client Exiting"]
zack has joined #ocaml
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
skylan has quit [Read error: 60 (Operation timed out)]
skylan has joined #ocaml
taw has quit [Read error: 113 (No route to host)]
taw has joined #ocaml
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
two-face has joined #ocaml
<two-face> re
ayrnieu has joined #ocaml
<whee> hola
<taw> hi
<ayrnieu> hello #Ocaml
<taw> hi ayrnieu
<two-face> hi ayrnieu
<whee> damn ocaml for making programs easy to extend
<whee> I can't stop working on this thing now :(
<two-face> i don't know if someone has seen my messages on caml-list, i received nothing
<taw> does dbfoge supports queries at all ?
<taw> or only schemas ?
<two-face> it does some selects
<taw> well, selects isn't much
<taw> it seems to be that ocaml has tons of unfinished stuff
<two-face> ask dbforge author
<taw> and it uses evil qpl
<taw> bad bad bad
<two-face> stop complaining
<two-face> what's the problem with QPL, dbforge is not a library
<taw> it is a problem
<taw> the custom of using qpl is very bad
<taw> they should use gpl or dual licences
<two-face> It is not a problem for standalone programs
<two-face> only for libraries
<taw> it is
<taw> very big problem
<two-face> no it isn't
<two-face> get a clue
<taw> if i can't use it together with gpl code
<two-face> then don't use gpl
<taw> freedom to use gpl is what open source is all about
<taw> they should use dual licences
<two-face> there is not need to with standalone programs
<taw> notion of 'standalone program' is a false one
<taw> very often you need to get some code from other program
<taw> if everything is gpl or dual gpl-something
<taw> then that's no probleb
<taw> with all these spooky licences it's very serious problem
<two-face> QPL is a freesoftware license
<taw> no it's not
<taw> not gpl-compatible = non-free
<two-face> you have no clue at all
<two-face> please read FSF pages
<two-face> then come back and we'll discuss
<taw> The Q Public License (QPL), Version 1.0.
<taw> It also causes major practical inconvenience, because modified sources can only be distributed as patches.
<taw> if i can't even setup a cvs with some software
<taw> or make tarballs of it
<taw> what "freedom" is that
<taw> "We recommend that you avoid using the QPL for anything"
<taw> even qt people realized that qpl is broken and dual licence with gpl now
<two-face> This is a non-copyleft free software license
<two-face> Please READ FIRST
<taw> b. When modifications to the Software are released under this license, a non-exclusive royalty-free right is granted to the initial developer of the Software to distribute your modification in future versions of the Software provided such versions remain available under these terms in addition to any other license(s) of the initial developer.
<taw> another nonfree clause
two-face has left #ocaml []
<taw> "in addition to any other license(s) of the initial developer"
<taw> that's not even copyleft
<taw> c. If the items are not available to the general public, and the initial developer of the Software requests a copy of the items, then you must supply one.
<taw> oh, so if i ever do anything that links with qpl app they can force me to send that to them
<taw> that's completely insane
<taw> "This license is governed by the Laws of Norway. Disputes shall be settled by Oslo City Court." is insane too
<taw> laws of norway apply in norway only
<whee> is there an interface to strftime in ocaml anywhere?
<whee> or some other method for time formatting :\
<whee> oh well
<whee> time to learn how the c interface works
ayrnieu has quit [Connection timed out]
<whee> this isn't going too well
<whee> can't get this char array to be returned as a caml string :|
<whee> and I take that back. there it goes. woo
<whee> I feel dirty using c :(
<taw> hehe
taw has quit [benford.freenode.net irc.freenode.net]
whee has quit [benford.freenode.net irc.freenode.net]
Segora has quit [benford.freenode.net irc.freenode.net]
pnou has quit [benford.freenode.net irc.freenode.net]
xtrm has quit [benford.freenode.net irc.freenode.net]
taw has joined #ocaml
whee has joined #ocaml
Segora has joined #ocaml
xtrm has joined #ocaml
pnou has joined #ocaml
gl has quit [benford.freenode.net irc.freenode.net]
emu has quit [benford.freenode.net irc.freenode.net]
Begbie has quit [benford.freenode.net irc.freenode.net]
gl has joined #ocaml
emu has joined #ocaml
Begbie has joined #ocaml
two-face has joined #ocaml
<two-face> pnou: ?
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
two-face has left #ocaml []
gl has quit [Read error: 54 (Connection reset by peer)]
gl has joined #ocaml
<taw> goodbye
taw has left #ocaml []
mr_bubbs has quit ["leaving"]
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
Yurik has joined #ocaml
<Yurik> re