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
yinnte has joined #ocaml
yinnte has quit ["leaving"]
ASau has joined #ocaml
<phubuh> hmm
<phubuh> when I execute an update with Dbi_postgres and mod_caml's Dbi, I get
<phubuh> Dbi_postgres: dbh 1: execute update pages set body = ? where title = ?
<phubuh> Dbi_postgres: dbh 1: finish update pages set body = ? where title = ?
<phubuh> Dbi_postgres: dbh 1: execute rollback work
<phubuh> Dbi_postgres: dbh 1: finish rollback work
<phubuh> which indicates that it undoed what it did, right? the update doesn't get updated.
<Demitar> Looks like it, looking in the database gives the definite answer as always.
<phubuh> nothing gets updated in the database.
<phubuh> oh, it looks like I need to do connection#commit :-)
<Demitar> Yes, that would be a natural way of using transactions. ;-)
<phubuh> yeah, but I didn't know this thing used transactions
<phubuh> and I expected it to commit after itself if it did so
mimosa has quit [Remote closed the connection]
buggs is now known as buggs|afk
Vincenz has joined #ocaml
Vincenz has quit [Client Quit]
ayrnieu has joined #ocaml
lus|wazze has quit ["Copyright is a temporary loan from the public domain, not property"]
ayrnieu has quit [Read error: 110 (Connection timed out)]
Demitar has quit ["Lämnar"]
ASau has quit ["Toffee IRC client for DOS v1.0/b535"]
Hadaka has quit [calvino.freenode.net irc.freenode.net]
wrunt has quit [calvino.freenode.net irc.freenode.net]
liyang has quit [calvino.freenode.net irc.freenode.net]
buggs|afk has quit [calvino.freenode.net irc.freenode.net]
Hipo has quit [calvino.freenode.net irc.freenode.net]
drlion has quit [calvino.freenode.net irc.freenode.net]
det has quit [calvino.freenode.net irc.freenode.net]
smkl has quit [calvino.freenode.net irc.freenode.net]
cm has quit [calvino.freenode.net irc.freenode.net]
wax has quit [calvino.freenode.net irc.freenode.net]
mw has quit [calvino.freenode.net irc.freenode.net]
teratorn has quit [calvino.freenode.net irc.freenode.net]
rox has quit [calvino.freenode.net irc.freenode.net]
lam_ has quit [calvino.freenode.net irc.freenode.net]
The-Fixer has quit [calvino.freenode.net irc.freenode.net]
themus has quit [calvino.freenode.net irc.freenode.net]
mattam has quit [calvino.freenode.net irc.freenode.net]
brwill_zzz has quit [calvino.freenode.net irc.freenode.net]
Riastradh has quit [calvino.freenode.net irc.freenode.net]
Smerdyakov has quit [calvino.freenode.net irc.freenode.net]
Hadaka has joined #ocaml
liyang has joined #ocaml
buggs|afk has joined #ocaml
rox has joined #ocaml
mattam has joined #ocaml
brwill_zzz has joined #ocaml
Hipo has joined #ocaml
wrunt has joined #ocaml
drlion has joined #ocaml
Riastradh has joined #ocaml
Smerdyakov has joined #ocaml
cm has joined #ocaml
lam_ has joined #ocaml
det has joined #ocaml
The-Fixer has joined #ocaml
wax has joined #ocaml
smkl has joined #ocaml
teratorn has joined #ocaml
mw has joined #ocaml
themus has joined #ocaml
mimosa has joined #ocaml
__buggs has joined #ocaml
buggs|afk has quit [Read error: 60 (Operation timed out)]
__buggs is now known as buggs
mattam_ has joined #ocaml
<phubuh> hmm, I'm having a bit of trouble formulating a lexer with ocamllex
<phubuh> it's supposed to lex a wiki syntax -- that is, plain text marked up with a very simple markup language that reads like real text. example:
<phubuh> foo _emphasis_ *strong emphasis* <link to another page>
<phubuh> | this, since it starts with " |", is a line of code
<phubuh> what I'm having trouble with is the code line syntax
<phubuh> if a lex regex had a "start of line" special character, it would be easy
mattam has quit [Read error: 110 (Connection timed out)]
mattam_ is now known as mattam
Evolux_ has joined #ocaml
<Evolux_> hello!
<Evolux_> how can i tell the :: operator, that i want a scalar at the right side and a list at the left side?
Vincenz has joined #ocaml
<Evolux_> is it possible to get the last element of a list?
<Evolux_> anybody alive?
<phubuh> Hi Evolux_
<phubuh> You can't add to the end of a list with the :: operator. The most common idiom is lst @ [value].
<phubuh> Beware, though, that lst @ [value] if lst is 1000 elements long, will require about 1000 steps.
<Evolux_> hm
<phubuh> It is often more efficient to use value :: lst to build your list in reverse, and then use List.reverse to get it in the right order.
<Evolux_> so if i want to search a list in reverse (from end to start)
<phubuh> I'd use List.reverse and then search it start to end
<Evolux_> is it ok to go through the list recursively and then comparing the elements from the end to the start?
<Evolux_> hm, I don't think i can use List.reverse
<Evolux_> how long does list.reverse take?
<phubuh> linear time, probably with a very small constant
<Evolux_> ok
<Evolux_> another question:
<phubuh> Err, sorry, it's called List.rev
<Evolux_> how can i check the return value of a function and return it again when it is > 0?
<Evolux_> thanks
<phubuh> Creating and reversing a list of [1 .. 10000] is instantaneous on my computer. :-)
<phubuh> return it again?
<phubuh> to check the return value of a function, you can use if and = or pattern matching
<Evolux_> yes, but i have to store it somehow, i think...
<Evolux_> x::l, z, p -> if searchReverseRec(l, z, p+1) != -1 then searchReverseRec(l, z, p+1);;
<Evolux_> something like that
Maddas has joined #ocaml
<Evolux_> damn... caml is a very complex language
<Evolux_> how can i do something like elseif?
<phubuh> else if
<phubuh> :-)
<Evolux_> does not work
<Evolux_> ah, i think i just reverse that damn list
<Evolux_> and write my own reverse function
<phubuh> Good idea. :-) It'll probably be faster, too.
<Maddas> Hello phubuh!
<phubuh> Hi Maddas!
<Maddas> Did you ever finish that BitTorrent client?
<phubuh> Nope. It can currently connect, chat, send files, and I don't remember whether it can receive files
<Maddas> OK!
<phubuh> It can't properly send the file list, though, so noone can request anything :-)
<Evolux_> thanks for your help
<phubuh> The file list is compressed using a Huffman encoder, and I think my encoder works, but other clients can't decompress it -- I think it's a header problem
<phubuh> No problem!
<phubuh> I was about to write a decompressor to test the compressor when I got bored :-)
Evolux_ has left #ocaml []
<phubuh> I'll probably resume work on it, one of these days
<Maddas> Nice!
<Maddas> I'd have a look at it, but I don't have any computer during weekdays anyway, and not too much time today
<phubuh> I started writing a Wiki in OCaml yesterday, btw :-)
<phubuh> You can _emphasize_ words, *really* emphasize them, and <create links>
<phubuh> I'm about to add code blocks and stuff, but to do so, I think I have to throw out ocamllex and ocamlyacc and parse the thing manually. Ugh.
<Maddas> Heh.
<Maddas> I don't have much time to do anything fun nowadays
<phubuh> :-(
<Maddas> Well, actually I would have the time, but not any computer :)
<Maddas> My laptop should have shipped over a month ago, but that's an entirely different story again.
<phubuh> Ouch. What kind of laptop?
<Maddas> 15" AlBook
<phubuh> Yow!
<Maddas> Indeed :)
<Maddas> If it were a PC laptop, I would have cancelled the order and bought a different one long ago.
<phubuh> Heh
<Maddas> But this is just too cool to not have :-)
<phubuh> Indeed
lus|wazze has joined #ocaml
<Maddas> Is the FFI hard? I'd like to use a small piece of code written in C
<Maddas> No point of trying if it is too hard though - haven't got too much time :-)
<phubuh> It's pretty simple
<Maddas> Okay, I'll read up then
<phubuh> http://www.phubuh.org/~public_html/sslcat.tar uses the FFI to use OpenSSL in OCaml
<Maddas> Heh, I don't need to do much really, one subroutine is all that I'll need :-)
<Maddas> phubuh: 404
<phubuh> oh, haha
<phubuh> doh :-)
<Maddas> But at least I managed to install O'Caml in the public terminals at my uni, so I'll get to play around a little at least
<phubuh> ah, nice
<Maddas> Hm. Can you FFI C++ with O'Caml too?
<phubuh> you'd probably have to wrap the objects in C
<Maddas> So it's probably better to just stick to C if you will use O'Caml with it too later on anyway
<phubuh> yeah, probably
<Maddas> What about Objective C? (just tell me if I'm annoying)
<phubuh> same thing :-)
<Maddas> Ok :)
<phubuh> but if you want to use Objective C code in OCaml, it's probably pretty easy to write C wrappers around the member functions of an object
<Maddas> Yeah, I guess.
<phubuh> there's also swig... but I don't know if it handles C++ or ObjC
<phubuh> ooh, it does do C++
<Maddas> Cool. I should look into it once
<Maddas> Oh, the existing framework is already in C, that makes everything easier.
<phubuh> how fortunate
<Maddas> But then again, I doubt that they will be happy if I just write the C(++) assignment in O'Caml :-)
<phubuh> haha
* Maddas sighs
Demitar has joined #ocaml
ragzter has joined #ocaml
ragzter has quit [Read error: 104 (Connection reset by peer)]
<phubuh> Phew! I finished writing the manual parser :-)
<phubuh> now there's code blocks!
<Maddas> hehe
<phubuh> hmm, why aren't these types compatible?
<phubuh> [> `Emphasized of string | `Link of string | `Text of string ] list
<phubuh> and
<phubuh> [< `Code of string
<phubuh> | `Emphasized of string
<phubuh> | `Link of string
<phubuh> | `Text of string ]
<phubuh> I am trying to use the first as the second, so no errors could occur
<Smerdyakov> Because polymorphic variants are for Perl users. :P
<phubuh> Haha. Actually, there's no reason for me to use them here
<Smerdyakov> Is it accidental that the first is a list and the secod isn't?
<Maddas> Smerdyakov: I hope "for Perl users" is a compliment :-)
<phubuh> Oops, I forgot to paste a list; the second type is also a list.
<phubuh> I mean I forgot to paste a line
<Smerdyakov> Maddas, no way!
<Demitar> phubuh, try restricting the type explicitly and see what happends.
* Maddas mentally smacks Smerdyakov
<phubuh> Too late, I already changed to a non-polymorphic variant :-)
<phubuh> Wheee!
<Demitar> phubuh, sending a correct mime-header would be nice. ;-)
<phubuh> Ooops. Hmm.
<Demitar> HTTP warning: Server didn't send Content-Type in header.
<phubuh> Should be fixed now.
<phubuh> HTTP/1.1 200 OK
<phubuh> Date: Sun, 09 Nov 2003 17:49:55 GMT
<phubuh> Server: Apache/1.3.29 (Unix) (Gentoo/Linux) mod_caml/0.91
<phubuh> Connection: close
<phubuh> Content-Type: text/html
<phubuh> :-)
<Demitar> Wii! *rejoices with phubuh*
<Demitar> phubuh, I think you have a bug. ;-) Check the wiki page, you probably reverse the rows somewhere.
<Demitar> And you should really make sure the client doesn't cache the edit pages.
<phubuh> Hahaha, oops.
<phubuh> Wiki is a way to generate documents on the fly community style http://wiki.org/ ---- /Demitar
<phubuh> How do I prevent clients from caching?
<Demitar> Much better. ;-)
<phubuh> Ah, and http://-prefixed links should leave the wiki.
Hadaka has quit [calvino.freenode.net irc.freenode.net]
lus|wazze has quit [calvino.freenode.net irc.freenode.net]
buggs has quit [calvino.freenode.net irc.freenode.net]
wrunt has quit [calvino.freenode.net irc.freenode.net]
liyang has quit [calvino.freenode.net irc.freenode.net]
Demitar has quit [calvino.freenode.net irc.freenode.net]
det has quit [calvino.freenode.net irc.freenode.net]
drlion has quit [calvino.freenode.net irc.freenode.net]
Hipo has quit [calvino.freenode.net irc.freenode.net]
smkl has quit [calvino.freenode.net irc.freenode.net]
mw has quit [calvino.freenode.net irc.freenode.net]
teratorn has quit [calvino.freenode.net irc.freenode.net]
wax has quit [calvino.freenode.net irc.freenode.net]
cm has quit [calvino.freenode.net irc.freenode.net]
mattam has quit [calvino.freenode.net irc.freenode.net]
mimosa has quit [calvino.freenode.net irc.freenode.net]
lam_ has quit [calvino.freenode.net irc.freenode.net]
themus has quit [calvino.freenode.net irc.freenode.net]
The-Fixer has quit [calvino.freenode.net irc.freenode.net]
rox has quit [calvino.freenode.net irc.freenode.net]
Maddas has quit [calvino.freenode.net irc.freenode.net]
Smerdyakov has quit [calvino.freenode.net irc.freenode.net]
Riastradh has quit [calvino.freenode.net irc.freenode.net]
brwill_zzz has quit [calvino.freenode.net irc.freenode.net]
eternite has joined #ocaml
<eternite> coucou tout le monde!
Demitar has joined #ocaml
lus|wazze has joined #ocaml
Maddas has joined #ocaml
mattam has joined #ocaml
buggs has joined #ocaml
mimosa has joined #ocaml
Hadaka has joined #ocaml
liyang has joined #ocaml
rox has joined #ocaml
brwill_zzz has joined #ocaml
Hipo has joined #ocaml
wrunt has joined #ocaml
drlion has joined #ocaml
Riastradh has joined #ocaml
Smerdyakov has joined #ocaml
cm has joined #ocaml
lam_ has joined #ocaml
det has joined #ocaml
The-Fixer has joined #ocaml
wax has joined #ocaml
smkl has joined #ocaml
teratorn has joined #ocaml
mw has joined #ocaml
themus has joined #ocaml
<Demitar> phubuh, http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 In essence "Cache-Control: no-cache"
<phubuh> Ah, thanks!
<phubuh> I believe I've fixed that now, along with outside linking.
TachYon has joined #ocaml
teratorn has quit [Read error: 104 (Connection reset by peer)]
eternite_0 has joined #ocaml
<yella> how do I represent a C function which has a callback function as argument in IDL (Camlidl) ?
<Demitar> Your preferably don't I suspect. ;-) http://caml.inria.fr/archives/200111/msg00275.html What do you need to do?
<yella> well a normal callback
<yella> currently im using 'typedef [abstract] void *handler' but i guess thats wrong
<yella> something like 'typedef void (*handler)(int a)' would be nice
eternite has quit [Read error: 110 (Connection timed out)]
[SkY] has joined #ocaml
[SkY] has left #ocaml []
<Demitar> One big problem is that there is no way to know how long the callback must be kept around...
<lus|wazze> also a caml function consists not only of a function pointer, but, as a closure, contains a pointer to the function's environment as well
<lus|wazze> which is not represented by the C function pointer
lus|wazze has quit ["Copyright is a temporary loan from the public domain, not property"]
<yella> hm wouldn't something like this work
<yella> type mult = int -> int
<yella> let f (a:mult) x = a x
<yella> f (fun x->x*x) 10
<yella> where we define mult in idl as 'typedef [mltype("int -> int")] void *mult'
lus|wazze has joined #ocaml
TachYon has quit [Remote closed the connection]
eternite_0 has quit ["Client exiting"]
async has joined #ocaml
<async> im getting a stack overflow in one of my functions... although i believe it is properly tail recursive
<Demitar> Could you paste it?
<async> let rec parsefile infile out =
<async> let str = readlines infile 1 in
<async> if (valid_line str) then
<async> (
<async> )
<async> ack
<async> lemme put it on a website
<async> infile has ~220k lines
<Smerdyakov> async, do you know Kun Gao?
<async> it crashes before it throws End_of_file
<async> nope
<async> is he some professor?
<Demitar> Could this be the culprit? output_string out ((list_to_string (cleanse (string_to_list str))) ^ "\n");
<Smerdyakov> No. He's a Cal undergrad who said he had introduced a friend to OCaml and gotten him hooked on it, but I guess that's not you. :)
<async> are you an undergrad?
<Smerdyakov> Nope. PhD student.
<async> under who?
<Demitar> One of those functions might overflow?
<Smerdyakov> Necula
<async> Demitar: they're relatively small
<async> just cleans up a string a little
<async> Smerdyakov: cool
<async> do you know Hilfinger?
<async> or Clancy?
<Smerdyakov> I've seen Hilfinger a lot, but I don't like him, and I don't know that I'd want to. :D
<Smerdyakov> I've seen Clancy much less, but I can pick him out of a crowd. Never spoken to him, either.
<async> hehe they're my profs
<async> for cs 61a
<Smerdyakov> Hilfinger goes to the programming systems related seminars a lot.
<async> hes a good guy
<Smerdyakov> He doesn't do research anymore, from what I've heard.
<async> oh
<Smerdyakov> Or at least doesn't have any students.
<async> tail recursive functions don't use the stack right?
<Smerdyakov> They use fixed stack space, yes.
<async> then wtf
<Smerdyakov> But you can use ocamldebug to find out where the actual loop is.
owll has joined #ocaml
owll has quit [Client Quit]
<async> this is cool - binford's law applies to file sizes on computers
<async> benford's
<async> too bad i can't tabulate all data due to stack overflow hehe
<Demitar> Well I've been unable to reproduce it using a 1000 line file.
<async> Demitar: i've been using a 220,000 line file
<Demitar> Well now I've been unable to reproduce it using a 200'000 line file. :)
<Demitar> The actual code I've been using is:
<Demitar> let valid_line _ = true
<Demitar> let rec parsefile infile out =
<Demitar> let str = input_line infile in
<Demitar> if (valid_line str) then
<Demitar> (
<Demitar> output_string out (str ^ "\n");
<Demitar> parsefile infile out
<Demitar> )
<Demitar> else parsefile infile out
<Demitar> ;;
<Demitar> parsefile (open_in "foo.txt") stdout
<Smerdyakov> async, if you haven't used ocamldebug yet to find the exact stack right before the crash, then you should do that before continuing here.
<Demitar> Try shotgun debugging. :) Remove things until it works... ;-)
<Demitar> Smerdyakov, how would one do that the best way? running and then backstepping and finally getting the backtrace? (I've never really befriended ocamldebug yet.)
<Smerdyakov> Demitar, look at the time number when it crashes. Run again, stopping a little before that time.
<async> Demitar: have you made it crash?
<Demitar> async, yes by making it obviously non-tail recursive. (returns an int eventually)
<Demitar> Smerdyakov, but then how do I get useful information about the stack? The backtrace lists thousands of #26187 Pc : 6192 Foo char 202
rox is now known as earth
<Demitar> Ah, using up does make things more useful since it displays the source line.
earth is now known as rox
<async> Demitar: the error is in Hashtbl
<Demitar> So you were using a hash without telling us? ;-)
<async> it has 10 entries!
<async> its an (int, int) table
<async> hmm ill try a list
<Demitar> But where is it overflowing really?
<Demitar> Couldn't it simply be the final temporary allocation by the hash that triggers the overflow?
<Demitar> It seems very odd if a hashtable with 10 entries would cause a stack overflow all by itself.
<async> i call Hashtbl.replace a bunch of times though
<async> yeah this is strange
Hipo has quit ["leaving"]
teratorn has joined #ocaml