vect changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn, ICFP'03 http://www.icfpcontest.org/, 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
async has quit [sterling.freenode.net irc.freenode.net]
Maddas has quit [sterling.freenode.net irc.freenode.net]
cm has quit [sterling.freenode.net irc.freenode.net]
Etaoin has quit [sterling.freenode.net irc.freenode.net]
Defcon7 has quit [sterling.freenode.net irc.freenode.net]
gim has quit [sterling.freenode.net irc.freenode.net]
mw has quit [sterling.freenode.net irc.freenode.net]
wax has quit [sterling.freenode.net irc.freenode.net]
Defcon7 has joined #ocaml
Etaoin has joined #ocaml
gim has joined #ocaml
cm has joined #ocaml
Maddas has joined #ocaml
async has joined #ocaml
wax has joined #ocaml
mw has joined #ocaml
Maddas_ has joined #ocaml
async_ has joined #ocaml
mw_ has joined #ocaml
axolotl has joined #ocaml
_cm has joined #ocaml
gim_ has joined #ocaml
_Defcon7 has joined #ocaml
async has quit [sterling.freenode.net irc.freenode.net]
Maddas has quit [sterling.freenode.net irc.freenode.net]
cm has quit [sterling.freenode.net irc.freenode.net]
Etaoin has quit [sterling.freenode.net irc.freenode.net]
Defcon7 has quit [sterling.freenode.net irc.freenode.net]
gim has quit [sterling.freenode.net irc.freenode.net]
mw has quit [sterling.freenode.net irc.freenode.net]
wax has quit [sterling.freenode.net irc.freenode.net]
_cm is now known as cm
_Defcon7 has left #ocaml []
_Defcon7 has joined #ocaml
<_Defcon7> there is any unix "tail" similar function in ocaml ?
<_Defcon7> like event triggering on data
gim_ has quit ["bonne nuit tout le monde"]
Vincenz has joined #ocaml
<_Defcon7> something to make an ocaml program to sleep ?
<_Defcon7> like nanosleep() syscall
<_Defcon7> anyone online ?
systems has joined #ocaml
systems has quit [Read error: 110 (Connection timed out)]
maihem has quit ["Client exiting"]
Etaoin has joined #ocaml
<_Defcon7> anyone online ?
<_Defcon7> let rec tail chid = print_endline in try (input_line chid) with End_of_file -> Unix.sleep(1) ;; (tail chid) ;;
<_Defcon7> characters 79-92:
<_Defcon7> This expression has type unit but is here used with type string
<async_> dont do two simecolons
<async_> after Unix.sleep
<_Defcon7> ops i wanted to write ::
<_Defcon7> 06:11:20 [root@spawn]:~# ocamlopt unix.cmxa prova.ml -o prova
<_Defcon7> File "prova.ml", line 4, characters 79-107:
<_Defcon7> This expression has type 'a list but is here used with type string
<async_> let rec tail chid = try print_endline; let str = input_line chid in (tail chid) with End_of_file -> (Unix.sleep 1)
<_Defcon7> h
<_Defcon7> oh
<async_> are you trying to go through a file?
<_Defcon7> im trying to tail a file
<_Defcon7> like unix "tail" command
<async_> ok
<_Defcon7> hmm i with to use print_endline to print the output of input_linr
<_Defcon7> input_line
<_Defcon7> s/with/wish
<async_> you need to do something like this:
<async_> let rec tail file last_line =
<async_> let line, eof = try (input_line file), false
<async_> with End_of_file -> "", true
<async_> in
<async_> if not eof then
<async_> else
<async_> last_line
<async_> ok in between if and else, insert tail file line
<async_> "tail file line"
<_Defcon7> how do i can execute 2 commands after with exception ?
<async_> command; last_line
<async_> so (Unix.sleep 1); last_line
<_Defcon7> uhmm
<_Defcon7> let rec tail chid = try print_endline (input_line chid) with End_of_file -> (Unix.sleep 1); tail chid;;
<_Defcon7> whats wrong here ?
<_Defcon7> it compiles but does nothing
<_Defcon7> ops
<_Defcon7> hehe
<_Defcon7> 6:31 am here :P
<async_> _Defcon7, if you use your tail function, you won't be able to tail very large files
<async_> you make a recusrive call within a try...with expression
<async_> so every time you make a recusrive call it adds to the stack
<async_> and it will overflow after ~30000 lines
<_Defcon7> ouch
<async_> that ugly thing i posted above preserves tail recursion
<_Defcon7> ill try it :)
<_Defcon7> i just started yesterday to play with ocaml
<_Defcon7> and yes this is what i've do in one day (rotfl)
<_Defcon7> :P
<_Defcon7> wow i understood your example
<Etaoin> I guess the only way to access elements of a tuple is to unpack it with pattern-matching?
<_Defcon7> its kewl
<_Defcon7> async, i inserted a "print_endline last_line;" after "if not eof then" but i get a syntax error
<_Defcon7> why that ?
<_Defcon7> (without my add-on compiles and _probably_ works)
<async_> let rec tail file last_line =
<async_> let line, eof = try (input_line file), false
<async_> with End_of_file -> "", true
<async_> in
<async_> if not eof then
<async_> tail file line
<async_> else
<async_> last_line
<_Defcon7> yes i tried this and works, but i want to print out the lines
<async_> you can just put print_endline before last line
<_Defcon7> so i inserted a print_endline after the "if not eof"
<async_> print_endline last_line
<_Defcon7> if not eof then
<_Defcon7> print_endline last_line;
<_Defcon7> tail chid last_line
<_Defcon7> else
<_Defcon7> last_line;;
<_Defcon7> this is what gives syntax err
buggs is now known as buggs|afk
Kinners has joined #ocaml
_Defcon7 is now known as Defcon7
lus|wazze has joined #ocaml
Kinners has left #ocaml []
<Etaoin> Defcon7: did you figure out that syntax error?
<async_> hes sleeping hehe
The-Fixer has quit ["Goodbye"]
<async_> Etaoin: new mexico tech
<async_> im from new mexico
<async_> you like soccoro?
<async_> socorro*
Vincenz has quit []
mattam_ has joined #ocaml
mattam has quit [Read error: 60 (Operation timed out)]
yurug has joined #ocaml
yurug has left #ocaml []
gim has joined #ocaml
arty has joined #ocaml
arty has left #ocaml []
mattam_ is now known as mattam
Demitar has joined #ocaml
The-Fixer has joined #ocaml
maihem has joined #ocaml
__buggs has joined #ocaml
buggs|afk has quit [Read error: 110 (Connection timed out)]
Maddas_ is now known as Maddas
<Defcon7> http://www.nectarine.info/misc/tail.txt <- whats wrong here ? this works only at ocaml toplevel, not compiled
<Demitar> Without looking I suspect you have an unresolved type.
<Demitar> (unresolved is probably the wrong word though)
<Demitar> It compiled just fine here though. ;-)
<Demitar> Do you try to compile it as a .txt file?
<Defcon7> no... .ml
<Defcon7> with ocamlopt
<Demitar> What is the error?
<Defcon7> it builds
<Defcon7> but doesnt work
<Demitar> Well do you have the "pd" file around?
<Defcon7> it should tail a file until eof, and when eof it should wait a bit and then try again to read from the file
<Defcon7> i have the file in the same dir as the program
<Defcon7> i also tried to strace ./tail and i see the "if not eof" never happens, it just loops and sleeps
<Defcon7> but in ocaml toplevel works...
<Demitar> Does it output anything?
<Demitar> Since it seems to be working just fine here.
<Defcon7> also compiled ?
<Demitar> Yes.
<Defcon7> *unf*
<Defcon7> what you have linked to it ?
<Demitar> unix.cmxa
<Defcon7> same as here :|
<Demitar> $ ocamlopt -v
<Demitar> The Objective Caml native-code compiler, version 3.07+2
<Demitar> Standard library directory: /usr/lib/ocaml/3.07
<Defcon7> The Objective Caml native-code compiler, version 3.04
<Demitar> How is it failing?
<Defcon7> a bit older
lus|wazze has quit ["Copyright is a temporary loan from the public domain, not property"]
<Defcon7> hmm you get the "pd" file printed ?
<Demitar> But how is it failing? Does it output anything? Does it output but not say anything when adding to the file? etc.
<Defcon7> outputs a \n and sleeps
<Demitar> Defcon7, yes, and when I do echo "foo" >> pd it adds more.
<Defcon7> 03:18:20 [root@spawn]:~# ocamlopt unix.cmxa prova.ml -o prova
<Defcon7> 03:18:29 [root@spawn]:~# ./prova
<Defcon7> 03:18:33 [root@spawn]:~#
<Defcon7> i have to go to lourdes.
<Demitar> Well how about not developing at root to begin with? :)
lus|wazze has joined #ocaml
<Defcon7> yes yes you are right :P
<Defcon7> same thing as user...
<Defcon7> probably is the compiler version
<Defcon7> for sure you know ocaml better than me...im playing with it from 2 days...
<Defcon7> do you see errors or tricky things in my code ?
<Demitar> What does your pd file contain?
<Defcon7> characters and newlines :)
<Defcon7> i created it with echo "sffsd" >> pd
<Defcon7> with some lines
<Demitar> You could of course add a "flush stdout;" right after the print_endline or before the Unix.sleep to ensure it's not breaking on something like that.
<Defcon7> oh
<Defcon7> trying
<Demitar> If that doesn't help it you can add some magic debugging. (Ie print_endline "foo"; to trace the program execution.
<Demitar> Or simply single-step the progam using ocamldebug.
<Defcon7> flush flush flush
<Defcon7> hehe
<Defcon7> finally works :D
<Defcon7> it was the flush thing
<Defcon7> probably because we was using pervasive fds and not Unix fds
<Defcon7> also unix fds need to be flushed ?
<Defcon7> ok not important now, the manual will tell me :)
<Defcon7> another thing about ocaml programming...
<Defcon7> i know ocaml as a very coincise programming style
<Defcon7> but this night when async tell me that "if" if has more than one command needs begin and end
<Defcon7> i was perplessed
<Defcon7> there is any other way ?
<Demitar> It's like this:
<Demitar> if <condition> then <statement>; or if <condition> then <statement> else <statement>;
<Demitar> Thus "foo ()" is a statement, "foo (); foo ()" is two statements.
<Defcon7> yep but im talking about begin and end thing...
<Demitar> You need to wrap them in a block by either begin end or ( ).
<Demitar> Or why not let () = <statement> in let () = <statement> in <statement> if you want to be obscure. ;-)
<Maddas> yup, you can use ( and ) if you don't like begin and end, although I find begin and end a bit more readable
<Maddas> Defcon7: Think of begin and end and ( and ) as something like { and } in other languages.
<Maddas> (C-like syntax)
<Defcon7> understood, cool :)
<Demitar> Maddas, now that was hard to read. ;-) "and end and ..."
<Maddas> s,rr5 A0
<Maddas> err
<Maddas> sorry
<Defcon7> probably thats because begin...end remembers me pascal\delphi ugly syntax :P
<Demitar> Well good indention is the key. :)
<Maddas> Defcon7: O'Caml has its own syntax, very unlike most other languages (who usually copy C's syntax more or less)
<Maddas> so it probably takes a bit getting used to :)
<Defcon7> Maddas someone should be totally crazy to choose ocaml
<Demitar> Maddas, so by copying ml it has it's own syntax? ;-)
<Defcon7> and the fact im here explains all
<Defcon7> haha :)
<Maddas> Demitar: well, ok, not really
<Maddas> but it's different than most mainstream languages at least :)
<Maddas> I should have said ML dialects, maybe
<Defcon7> the syntax is the minor problem...it just needs to be learned...when learned any (logically right) syntax is good
<Demitar> Defcon7, actually people tend to experiment with ocaml and then get hooked not wanting to go back to languages that can segfault. :)
<Defcon7> hehe, yes i also noticed this ocaml has a lot of cool features
<Defcon7> starting from the fact that it can be also called an high-level language and the speed is near to a C program
<Maddas> Demitar: same here
<Maddas> except that I'm forced to use C/C++ :)
<Demitar> Of more importance is usually that you can write slow programs in any language. :)
<Maddas> Defcon7: yeah, the syntax is just a hurdl in the beginning.
<Maddas> hurdle, even
<Defcon7> for now, i like ocam :)
<Demitar> Yes the first few times I looked at it I was just perplexed by the syntax. ;-) (Far too long in C/C++/python land I guess. :)
<Maddas> Same here, Demitar
<Maddas> And seeing all the rules about when you can omit the ';' dazzled me a bit
<Defcon7> if not eof then
<Defcon7> (
<Defcon7> print_endline last_line;
<Defcon7> Pervasives.flush Pervasives.stdout;
<Defcon7> tail chid;
<Defcon7> )
<Defcon7> coool :)
<Demitar> The worst part was to come to the realization how function application works, fun(arg1,arg2,...) sits very deep it seems. :)
<Defcon7> (that ugly begin...end has go away...ghgh)
<Demitar> Defcon7, Pervasives is the "initially opened module". Ie, just do flush stdout;
<Defcon7> nope
<Demitar> Why not?
<Defcon7> it try to use unix stdout
<Defcon7> and give an error
<Demitar> Ah, you opened Unix. ;-)
<Defcon7> yup i needed sleep
<Defcon7> theres another sleep out of unix ?
<Defcon7> sleep or nanosleep or something like that
<Maddas> You don't need to open Unix to use the functions in Unix
<Defcon7> oh
<Defcon7> (*whooops*)
<Maddas> opening it just "changes namespace", or however you say, by importing Unix functions into "empty" namespace
<Demitar> Yes, opening is done automagically when doing Module.fun.
<Defcon7> understood :)
<Maddas> Yes. The advantage you gain by opening is say "something" instead of "Unix.something"
<Demitar> Also, you never actually use Printf, print_endline is in Pervasives.
<Defcon7> i have to go now...but you will see me again in the next hours :§)
<Defcon7> thanks for the help it was pleasant
<Defcon7> finally an helpful channel
<Maddas> heh :)
<Defcon7> :)
<Demitar> When we are awake we usually are. :)
<Defcon7> bbl :)
chrisu has joined #ocaml
chrisu is now known as noss
demitar_ has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
demitar_ is now known as Demitar
eternite has joined #ocaml
<eternite> hello!
<Demitar> Greetings eternite.
malc has joined #ocaml
malc has quit ["no reason"]
whee has joined #ocaml
Etaoin has quit ["Client exiting"]
<noss> how well does ocaml's Big_int implementation perform?
lus|wazze has quit ["Copyright is a temporary loan from the public domain, not property"]
<eternite> Lower than C GMP.
<noss> lower as in better or worse?
<eternite> worse(a factor 10 or 100) : But during I tests only the multiplication.
<Demitar> Everything except int and int/float arrays is boxed, go figure. :)
<noss> are bigints implemented in ocaml or native?
<Demitar> Umm.. the underlying data is native but it's boxed for the gc.
<eternite> I think algo are implemented in totaly different way in Big_int and GMP
<eternite> There are a lot of "asm" in the source of GMP...
<Demitar> Ah GMP, well I shouldn't say too much then.
<noss> is there little interest in getting these things fast?
<eternite> If can go faster, you can have more digits
<Smerdyakov> MLton has a fast GMP interface!
<noss> but i want a nice language to implement a slave for crypto-calculations. sigh.
<eternite> I was talking about 1 or more million of digits...
<eternite> :)
<Smerdyakov> noss, you think OCaml is nice but not SML?
<mellum> I think there are also GMP bindings for Ocaml
<noss> Smerdyakov: i dont actually thing ocaml is nice in the FP category, it is more that i find FP nice and i want/need a language that compiles to efficient code and has a few features i need.
<Riastradh> noss, so what's wrong with SML?
<noss> Riastradh: i dont know. did I say something is wrong with SML?
<Riastradh> You implied it.
<noss> if i implied it, then i guess SML isnt a language in the FP category.
<Riastradh> It isn't?
<Riastradh> Now you're just confusing me.
<Smerdyakov> SML is the single language in the world most similar to OCaml.
<Smerdyakov> SML = Standard ML
<Riastradh> What about Caml Light?
<Smerdyakov> Please. You're spoiling my dramatic effect.
<Riastradh> Awww, I'm sowwy, Smewdyakawf.
* Demitar plays some ominous music.
noss has quit ["Client exiting"]
Etaoin has joined #ocaml
ayrnieu has joined #ocaml
<mellum> Does anybody know why Ocaml has no call/cc?
<Demitar> Are you asking about FFI?
<Riastradh> CALL/CC has nothing to do with FFIs. (well, it can make the external language suffer much pain, I guess)
<Riastradh> s/external/foreign/1
<Demitar> Ah, now I recognise it. :)
mimosa has joined #ocaml
noss has joined #ocaml
Etaoin has quit [Read error: 104 (Connection reset by peer)]
eternite has quit ["Arlg connection crash!"]
<noss> what platforms do the compilers target?
<ayrnieu> The O'Caml distribution describes which platforms the native-code compiler supports; I don't know of any particular limitations on the bytecode compiler.
Demitar has quit ["Bubbles..."]