irc.freenode.net changed the topic of #ocaml to: OCaml 3.08 "Bastille Day" Release available ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn , A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ , A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list
lus|wasz has joined #ocaml
vezenchio has quit [Read error: 110 (Connection timed out)]
lus|wasz is now known as vezenchio
lus|wasz has joined #ocaml
TylerE has joined #ocaml
<TylerE> I'm having trouble with the Graphics library under Windows (MinGW)
<TylerE> I typed in a simple program from the merjis.com tutorials
<TylerE> used ocamake to build it
<TylerE> like so:
<TylerE> $ ocamake.exe graphics1.ml -o graphics.exe
<TylerE> Output:
<TylerE> graphics1.ml
<TylerE> Linking...
<TylerE> Error while linking craphics1.cmo: Reference to undefined global 'Graphics'
<TylerE> Linking failed
<TylerE> any ideas?
<TylerE> the release notes make me think this *should* work
<Smerdyakov> No, since you aren't including the Graphics library....
<Smerdyakov> Though I know nothing about 'ocamake'.
<Smerdyakov> You need to specify libraries explicitly with the real compiler program.
cjohnson has quit [Read error: 54 (Connection reset by peer)]
wegzze has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
vezenchio has quit [Read error: 110 (Connection timed out)]
lus|wasz has quit ["I thought what I'd do was, I'd pretend to be one of those deaf-mutes"]
TylerE has quit [Read error: 110 (Connection timed out)]
barzhaz has joined #ocaml
barzhaz has left #ocaml []
gim has quit ["pouf"]
mpc has joined #ocaml
cjohnson has quit ["Leaving"]
mpc has quit []
lmbdwr has left #ocaml []
pango has quit [Nick collision from services.]
pango_ has joined #ocaml
mrsolo has joined #ocaml
mpc has joined #ocaml
mpc has quit [Client Quit]
zigong__ has quit [Remote closed the connection]
pnou has quit ["brb"]
mlh has quit [Client Quit]
mrsolo has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
CoolPops has joined #ocaml
<CoolPops> Is it possible for the Str module to match lazily? i.e. I had a ''very'' hard day today ''at'' work. ... a regexp: "''\\(.*\\)''" would return everything from very ... at but I would like to match very as 1 match, and at as another.
<mflux> str may not be able to (I don't remember w/o referring to the documentation), but pcre is much better regular expression matcher anyway
<mflux> and it would support notation .*?
<CoolPops> mflux: is that an addon?
<mflux> yes
<CoolPops> mflux: ok. I'll look into it.
<CoolPops> mflux: thanks for the pointer.
<mflux> glad to be of assistance
Herrchen has joined #ocaml
pango_ has quit ["Client exiting"]
alex-i_ has joined #ocaml
alex-i has quit [Read error: 113 (No route to host)]
pango has joined #ocaml
alex-i_ has quit [Read error: 60 (Operation timed out)]
CoolPops has quit [Read error: 110 (Connection timed out)]
shawn_ has joined #ocaml
eternite has joined #ocaml
_shawn has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
mrsolo_ has joined #ocaml
gpciceri has joined #ocaml
moonfish has quit [Read error: 54 (Connection reset by peer)]
bk_ has joined #ocaml
ita has joined #ocaml
<ita> type seg = {mutable x:int; mutable next: seg; mutable prev:seg} && let newseg a = let rec ct = {x=a; pprev=ct; nnext=ct} in ct;; is all i needed for a doubly linked list
<karryall> ita: except you have nothing to represent an empty list
<ita> no need to
ita has quit [Remote closed the connection]
ita has joined #ocaml
gpciceri has quit ["Leaving"]
karryall has quit ["tcho"]
ita has quit ["Konversation terminated!"]
buggs|afk has joined #ocaml
buggs has quit [Nick collision from services.]
buggs|afk is now known as buggs
eternite has quit ["Ocaml:http://caml.inria.fr/"]
Iter has joined #ocaml
zigong has joined #ocaml
Iter has quit [leguin.freenode.net irc.freenode.net]
Iter has joined #ocaml
vezenchio has joined #ocaml
mflux has quit [Remote closed the connection]
mflux has joined #ocaml
Robert has quit ["brb"]
mpc has joined #ocaml
gpciceri has joined #ocaml
_fab has joined #ocaml
<pango> -rw-rw-r-- 1 root mldonkey 62 2004-09-19 12:38 .htaccess
<pango> wtf ?
<pango> oups wrong chan :)
gpciceri has quit ["Leaving"]
Robert has joined #ocaml
Robert has quit ["brb (grrr...)"]
mpc has quit []
<Smerdyakov> Only COMMUNITS say "oups"!
<pango> Smerdyakov: only dyslexics say communits
mpc has joined #ocaml
<z|away> Bastard children of 'ol Karamazov are known to have many problems...
<Smerdyakov> Like buggering apes
Robert has joined #ocaml
<mflux> "dyslexics of the world, UNTIE!"
* Robert unties.
mpc has quit []
monochrom has joined #ocaml
vezenchio has quit [Read error: 110 (Connection timed out)]
mpc has joined #ocaml
mpc has quit []
pango has quit [Nick collision from services.]
pango_ has joined #ocaml
pango_ is now known as pango
mrsolo_ has quit ["Leaving"]
mrsolo_ has joined #ocaml
cjohnson has joined #ocaml
lodewijk has joined #ocaml
Herrchen has quit ["leaving"]
<lodewijk> does anyone know how to get the integer value from the abstract Unix.file_descr (which is an integer) ?
<Robert> What do you need it for?
<lodewijk> I'm juggling some of them and it would help print_string debugging.
<Robert> Sorry, I have no idea.
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<lodewijk> hmm. I guess I'll write a small C stub to do it then. thanks anyway :)
lodewijk has quit ["bye"]
<mflux> yeah, I've wanted that sometimes too
<mflux> useful if you want to strace a program and get some useful information out of it
<Smerdyakov> In SML/NJ, there is an Unsafe.cast : 'a -> 'b function you could use.
<Smerdyakov> Maybe OCaml has something similar.
<mflux> hmm, there are some black magic functions, but I haven't given them a look
vegai has joined #ocaml
<Smerdyakov> Well, loooook who's here!
<monochrom> Ocaml has oo.magic or something.
<Riastradh> Obj.magic
<vegai> howdy ho;
gpciceri has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
mpc has joined #ocaml
<vincenz> hi
<Smerdyakov> No
gpciceri has quit ["Leaving"]
cjohnson has quit [Read error: 54 (Connection reset by peer)]
cjohnson has joined #ocaml
Iter has quit [Read error: 110 (Connection timed out)]
tnks has joined #ocaml
<tnks> hi all.
<tnks> I was curious -- Does anybody here find Haskell inadequate compared to OCaml?
<tnks> (not in which ways).
<tnks> sorry. . . I meant "(in which ways)"
<Smerdyakov> The module system is horrible.
<Smerdyakov> And there aren't any good compilers for producing efficient object code.
<monochrom> OCaml has objects, classes, subtyping.
<monochrom> Now, I say this because I find subtyping and extensible records useful.
<monochrom> For example "the type of all records that has the field x:int, all other fields unconstrained and I don't care".
<monochrom> You can at least mimic that with object/class :)
<monochrom> Alright, you can also mimic some of that with Haskell's type class...
<monochrom> OCaml is eager. Some people find that comforting.
<dan2> is there any way to make mutable types in OCaml
<Smerdyakov> The mutable keyword....
<Smerdyakov> Anyone want to help me test my SML-based PHP replacement?
<dan2> Smerdyakov: when using mutable, how do I update variables
<Smerdyakov> dan2, read the tutorial in the manual.
* Smerdyakov leaves.
<Smerdyakov> Anyone who wants to try the web thing, see http://smlweb.sf.net/ . You need to check it out from CVS currently to install it.
<monochrom> let x = ref 0;;
<monochrom> x := !x + 1;;
<dan2> monochrom: thanks
_fab has quit [Read error: 113 (No route to host)]
<dan2> hmm
<dan2> let fib n =
<dan2> let k = ref 1 and a = ref (of_int 1) and b = ref (of_int 0) and c = ref (of_int 0) in
<dan2> while k < n do
<dan2> k := (incr !k);
<dan2> c := !b;
<dan2> b := !a;
<dan2> a := add !b !c;
<dan2> done
<dan2> !k;;
<dan2> can someone tell me whats wrong
<Riastradh> *HURK*
<Riastradh> Just about everything is wrong with that function.
<dan2> ;)
<dan2> Riastradh: how should I fix it
<Riastradh> Rewrite it entirely. Remove all references. Use a recursive loop.
<dan2> Riastradh: no
<dan2> Riastradh: recursive loop is bad
<Riastradh> Why?
<dan2> Riastradh: its the leading reason why I am not getting as good performance C
<dan2> as C
<mattam> i doubt x is ever different from fib x
<Riastradh> No, dan2.
<mattam> it doesn't type-check anyway
<dan2> Riastradh: being able to reuse variables would make it so it doesn't have to constantly allocate memory for every variable
<Riastradh> There are almost innumerable other factors to consider.
<dan2> Riastradh: I don't want a recursive function, how do I make *THIS* work
<Riastradh> Yet you don't seem to mind allocating superfluous references on the heap and performing a ton of heap loads & stores.
<dan2> Riastradh: I don't care, let me complete this
<Riastradh> dan2, do you know the saying 'a good Fortran programmer can write Fortran in any language?'
<dan2> Riastradh: yes... just wtf should I do to fix this
<dan2> I DON'T WANT A RECURSIVE FUNCTION
<Riastradh> Writing Fortran in OCaml won't help you fix anything.
<mattam> dan2: make it type-check first
<dan2> mattam: uhh?
<Riastradh> Why not? Trust me: recursion is _NOT_ the reason that the compiled OCaml code runs more slowly than the compiled C code.
<dan2> Riastradh: its the garbage collector
<mattam> k is used as an int and an int ref as well for example
<dan2> Riastradh: and not having to continuously allocate memory is a good thing
<Riastradh> dan2, can you demonstrate that the garbage collector is invoked at all during a call to a recursive fib?
<dan2> Riastradh: yes, its eating 92% of the time during a run of fibonacci up to 200000
<Riastradh> I don't see any reason why it should be; there is no heap allocation, assuming you use the same algorithm as you use in that Fortran code.
<dan2> Riastradh: I profiled the code
<Riastradh> Were you using regular ints or one of the bignum libraries when you performed this profiling?
<pango> dan2: using the same iterative algorithm you just described ?
<dan2> Riastradh: the same GMP that Numerix uses
<dan2> pango: no, a recursive
<monochrom> Hrm, what are those of_int things?
<dan2> monochrom: for translation to GMP integers
<Riastradh> There's your reason, then. _Bignums_ require heap allocation. It is entirely unrelated to any imagined overhead of recursion.
<dan2> Riastradh: ironically, in C, I preallocated all the memory using some logic, and it BURNS the ocaml
<dan2> Riastradh: .6 seconds for 200000
<Riastradh> Your Fortran code will have the same problem, only it'll also incur extra overhead for the heap-allocated references.
<Riastradh> Did you pre-allocate the _bignum_ memory or what was used for the _variables_?
<dan2> Riastradh: the memory for bignum
<monochrom> Preallocation is neat. But don't be unfair.
<Riastradh> Exactly. Even your Fortran-in-OCaml code still doesn't do that.
<dan2> /*
<dan2> * fib(n) is exponential, number of bits is logarithmic
<dan2> * thus, number of bits is a linear function and seems
<dan2> * to converge near n/1.44
<dan2> */
<dan2> unsigned long size = (double)n / 1.44;
<Riastradh> Just so show that you're wrong, since you apparently don't trust me, I shall help you fix your Fortran code: what's the type of k?
<Riastradh> s/so show/to show/1
<dan2> Riastradh: k is an integer
<Riastradh> An int?
<dan2> well, int ref
<Riastradh> Right.
<Riastradh> What is the type of (>)?
<Riastradh> ...oh, bother.
<Riastradh> Never mind; ignore that.
<dan2> oh, now I understand :)
<Riastradh> What's the type of n?
<Riastradh> OK.
<monochrom> Hrm, is int in ocaml boxed?
<dan2> n is integer
<Riastradh> dan2, are you sure k is an _int_ ref?
<dan2> (non ref, it should be immutable)
<monochrom> Are, boxed.
<dan2> Riastradh: why wouldn't it?
<mattam> monochrom: not int's, no
<Riastradh> ...oh, sorry, never mind.
<monochrom> So for example I can use the full 32 bits?
<Riastradh> dan2, so you see what's wrong with your code?
<dan2> not entirely
<Riastradh> No, monochrom. There still need to be type tags.
<dan2> just the !k > n part
det has quit [Read error: 110 (Connection timed out)]
<mattam> monochrom: 31 bits
<monochrom> Alright, you're right.
<Riastradh> What's the type of incr, dan2?
<mattam> and 63 on 64 bits arches IIRC
<dan2> Riastradh: the compiler is only complaining about that last bit, !k;;
<dan2> Riastradh: let incr = function x -> x+1
<mattam> hehe
<Riastradh> You defined incr yourself?
<dan2> yes
<mattam> that's definitely funny
<Riastradh> Oh, OK. There's a system incr function that destructively increments the contents of its argument.
<Riastradh> ...(its argument is of type int ref)
<dan2> Riastradh: I didn't know
<dan2> Riastradh: is there something wrong with my function?
<Riastradh> No, not at all.
<dan2> ok
<dan2> Riastradh: so what is wrong with the last part of the function, the !k;;
<monochrom> !k is n at the end.
<dan2> monochrom: ?
<Riastradh> Excuse me a moment.
chris has joined #ocaml
<dan2> monochrom: good call :)
<dan2> monochrom: didn't see that for a moment
<dan2> monochrom: should be a
<monochrom> Hrm, why didn't ocaml perform dead-code removal so that the code ran fast when you had !k? :)
<dan2> :)
<dan2> monochrom: its complaining about syntax on that !a;;
<mattam> because then compile times would be higher i suppose :)
<monochrom> Ah, ocaml didn't know that "add" is pure.
<Riastradh> dan2, try putting a semicolon after the 'done'.
<dan2> monochrom: why do I have to dereference in this
<dan2> c := !b;
<dan2> b := !a;
<dan2> I just want the reference anyhow\
pango has quit [Nick collision from services.]
pango_ has joined #ocaml
<dan2> lets not spend time dereferencing then referencing again
<Riastradh> No, you don't want the reference. First of all, what you're doing there isn't variable assignment: it's _reference_contents_ assignment.
<monochrom> Because references are not pointers.
<monochrom> Well, references are pointers under the hood, but on the surface there is a syntactic distinction.
<monochrom> I'd wager that c:=!b is translated to mere pointer copying.
<dan2> oh
<dan2> ok
shammah has joined #ocaml
<Riastradh> Note, however, that compilers for functional languages tend not to spend much effort in optimizing mutable references.
<pango_> dan2: what about http://concept.free.free.fr/fib/fib.ml ?
<Riastradh> He wants to be proven wrong about the speed benefits of Fortran code in OCaml, pango_.
<pango_> Riastradh: yes, so it should compare his program against this one, not against one doing f(n) = f(n-1) + f(n-2)
<Riastradh> Oh, I see.
<pango_> dan2: btw, replace the last line with ignore (fib n), or you'll also measure the time converting the result to a string...
<monochrom> Ah!
<dan2> pango_: already have one of those
<pango_> dan2: I guess you checked the time spent in gc ?
<dan2> hmm, is there anyway to get the profiler to spit out total time
<dan2> pango_: yes, majority of time was spent in gc, but less than that of the recursive
<dan2> pango_: like 7% less
<dan2> pango_: seemed faster than recursive
<dan2> how do I get gprof to spew out total time
mpc has quit []
<pango_> here almost 92% of the time is spent adding bigints...
<dan2> pango_: your version is significantly slower than mine
<dan2> and gmp is much faster than big_int
<pango_> dan2: so what
<dan2> pango_: most of my time is being spent in GC as I said
<pango_> dan2: then find why
<dan2> pango_: what number did you test it on
<Riastradh> It's obvious why. He's allocating a lot of memory to store bignums.