systems 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| Early releases of OCamlBDB and OCamlGettext are available | Caml Weekly news http://pauillac.inria.fr/~aschmitt/cwn/
docelic|away is now known as docelic
Smerdyakov has joined #ocaml
pattern_ has joined #ocaml
lament has joined #ocaml
rhil has quit ["reboot"]
lus|wazze has joined #ocaml
async has quit ["leaving"]
async_ has joined #ocaml
<async_> hey
async_ is now known as async
<Smerdyakov> Hi!
Smerdyakov has quit ["sleep"]
lament is now known as Offler
Offler is now known as lament
lament has quit ["THE FIRST AMENDMENT DOES NOT COVER BURPING"]
lus|wazze has quit ["I personally think we need public floggings of senators that do stupid things. Think about it: It would condition them not to]
mattam has joined #ocaml
TachYon has joined #ocaml
<mrvn> moin
__DL__ has quit [Read error: 54 (Connection reset by peer)]
Demitar has joined #ocaml
demitar_ has joined #ocaml
demitar_ has quit [Client Quit]
__DL__ has joined #ocaml
rhil has joined #ocaml
rhil is now known as rhil_zzz
Demitar has quit ["There are bubbles in the air..."]
TachYon has quit [Remote closed the connection]
TachYon has joined #ocaml
wrunt has quit ["leaving"]
Zadeh has quit [Read error: 104 (Connection reset by peer)]
gene9 has joined #ocaml
gene9 has quit [Read error: 54 (Connection reset by peer)]
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
det has joined #ocaml
Yurik__ has joined #ocaml
Yurik_ has quit [Read error: 104 (Connection reset by peer)]
det has quit ["ircII EPIC4-1.1.2 -- Are we there yet?"]
lus|wazze has joined #ocaml
<mrvn> I wonder if I can use the same format cps constructs for input and output somehow.
<Riastradh> What do you mean?
<mrvn> val netchar : UnixIO.t -> ('a -> unit) -> (char -> 'a) -> unit
<mrvn> val netchar : UnixIO.t -> 'a -> char -> 'a
<mrvn> The first one reads a char, the second one writes a char.
<mrvn> Same for netuint8 netuint16 netuint30 netint32 netint64
<mrvn> To read something you do "schedule_read unixIO (netline '\n' $ netline '\n' $ netline '\n') (fun x y z -> ...)
<mrvn> to write "schedule_write unixIO (netline '\n' $ netline '\n' $ netline '\n') x y z"
<Riastradh> What does $ do?
<mrvn> $ combines two read/write format thingies into one.
<mrvn> let ($) x y unixIO =
<mrvn> let x = x unixIO in
<mrvn> let y = y unixIO in
<mrvn> fun cont reader -> (x (y cont) reader)
<mrvn> At the moment I have netcahr, netuint8,... all as input and output variant.
<mrvn> Would be nice to have only one cause than one could just open the module.
<mrvn> And use the same ( x $ y $ z ) format for input and output.
<mrvn> That in turn would ensure that what you read from the network is what you write.
<mrvn> I guess I have to make format a pair of input and output format and then just throw the wrong one away.
TachYon has quit [Remote closed the connection]
rhil_zzz is now known as rhil_ATL
Smerdyakov has joined #ocaml
Smerdy has joined #ocaml
Smerdy has quit [Remote closed the connection]
<mrvn> juhu, input and output now works asynchronous via CPS style.
<mrvn> Next step is a simple http protokol to fetch a file.
<lus|wazze> [18:28:05] <mrvn> juhu <-- you don't happen to be german, do you?
<mrvn> I am
<lus|wazze> soso :)
<lus|wazze> sind wir ja schon zwei
<mrvn> mellum auch
<lus|wazze> awas
<lus|wazze> jaja
<lus|wazze> ocaml's popularität in deutschland wächst scheinbar :p
<async> is it possible to open a string as an input_channel?
<mrvn> you can make a channel from a stream and a stream from a string.
<async> how do you make a stream from a string
<mrvn> fun i -> s.[i] and then stream from function
<async> hmmm
<mrvn> Why do you need an input_channel?
<async> mrvn: well i have a string that contains a binary integer... and i want to read this integer
<async> mrvn: and pervasives has val input_binary_int : in_channel -> int
<async> so i'd like to convert this string to an in_channel
<Riastradh> fun i -> Some s.[i] you must mean.
<mrvn> Read an integer encoded in binary format from the given input channel. See Pervasives.output_binary_int. Raise End_of_file if an end of file was reached while reading the integer.
<mrvn> Thats not realy a binary int.
<async> yeah thats probably not the best idea... i might use the Scanf module
<mrvn> You want something like this:
<mrvn> let buffer_read_uint30 buffer =
<mrvn> let i1 = buffer_read_uint8 buffer in
<mrvn> let i2 = buffer_read_uint8 buffer in
<mrvn> let i3 = buffer_read_uint8 buffer in
<mrvn> let i4 = buffer_read_uint8 buffer in
<mrvn> i1 * 16777216 + i2 * 65536 + i3 * 256 + i4
<mrvn> or a C function
Vincenz has joined #ocaml
<Vincenz> Hi
<Vincenz> Any Ocaml teams needing another person?
reltuk has joined #ocaml
<Smerdyakov> Teams?
<Riastradh> ICFP contest teams, presumably.
* Vincenz nods
<Vincenz> guess noot
<mellum> Maybe we should for an #ocaml team.
<mellum> s,for,form,
* Riastradh is already going to be spying on the #haskell team...so he'll havve more channel teams to spy on!
<async> isn't the contest in august?
<Vincenz> nope
<Vincenz> that's what I thought :(
<async> url?
<Riastradh> It's on the last three days of June.
<Vincenz> is there such as continuations for Ocaml/
<Smerdyakov> I don't know, but it's possible to include it. (SML/NJ does.)
<Vincenz> is it possible to implement them in Ocaml or do you need to modify the compiler/
* mellum never really understood continuations
* Vincenz is trying to grok themn
<Riastradh> f (g x) <- The application 'g x' has a continuation there, often notated with a hole []. So, that could be shown as: f [] When g returns, it puts a value into that hole.
<Riastradh> Did that so far make sense?
<Vincenz> yes
<Smerdyakov> Vincenz, you'd probably need to modify the compiler... unless OCaml already has an almost identical feature.
<Riastradh> With callcc, the 'current continuation' -- e.g., in the case of 'g x' there, that hole I wrote -- can be captured and reified into a first-class value.
<async> have any of you done the contest before?
<Smerdyakov> Vincenz, do you know about setjmp and longjmp in C?
<Riastradh> So, you could do: f (callcc (fun k -> ...)) and in ..., 'k' is bound to a continuation.
<Riastradh> The function 'throw' puts a value into the hole a continuation represents.
<Smerdyakov> In C terms, a continuation is like a stack state and a program counter.
<Riastradh> If you did: f (callcc (fun k -> throw k 5; print_string "this will never be printed")), as the string shows, it won't be printed, because the call to 'throw' put 5 into the hole in f [], and then the program continued with 'f 5'.
<Riastradh> Did that make sense so far?
<Riastradh> Hello?
* Riastradh drops a pin.
<Vincenz> sorry
<Vincenz> I get the basis for cc's
<Vincenz> just when they start being combined and stuff
* Riastradh was also talking to mellum.
<Smerdyakov> There's your first mistake: talking to mellum. :D
Smerdyakov has quit ["out on the town"]
* Vincenz stretches and states he starts an #ocaml team
Vincenz changed the topic of #ocaml to: http://www.icfpcontest.org -> join #ocaml team, contact Vincenz | 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| Early releases of OCamlBDB and OCamlGettext are available | Caml Weekly news http://pauillac.inria.fr/~aschmitt/cwn/
Demitar has joined #ocaml
<Vincenz> so what does (call/cc call/cc) do?
<Riastradh> In Scheme, it captures the current continuation.
<lus|wazze> it returns call/cc ?
<lus|wazze> or no
<lus|wazze> depends on the exact definitions
<lus|wazze> if call/cc expects a function which takes a continuation this doesnt work
<lus|wazze> because call/cc then wouldnt be a function which takes a continuation
<mrvn> There is a call/cc for ocaml that uses fork(). Its a ugly hack.
<Riastradh> It's the same as (call/cc (lambda (k) (call/cc k))).
<Riastradh> K is the continuation of the outer function call.
<mrvn> If you transform your code to CPS implementing a call/cc becomes just another simple higher order function.
<Riastradh> K is therefore called with the continuation of the LAMBDA.
<Riastradh> The continuation of the LAMBDA is the continuation of the outer function call, due to tail-call elimination. (which is really eliminating some continuations -- making shortcuts to others)
<Riastradh> So control jumps to the continuation of the outer function call, and the value put in the continuation there is itself.
<Vincenz> ah
<Riastradh> It's pretty much the same as (call/cc (lambda (k) k)), with some indirection, and simpler.
<Riastradh> That is, simpler to write.
<Riastradh> More complicated semantically.
<mrvn> > newtype Continuation r a = Continuation { runContinuation :: (a -> r) -> r }
<mrvn> >
<mrvn> > instance Monad (Continuation r) where
<mrvn> > return x = Continuation (\k -> k x)
<mrvn> > p >>= f = Continuation (\k -> runContinuation p (\x -> runContinuation (f x) k))
<mrvn> > fail str = Continuation (\k -> error str)
<mrvn> > callcc :: ((x -> Continuation r y) -> Continuation r x) -> Continuation r x
<mrvn> > callcc g = Continuation (\k -> runContinuation (g (\x -> Continuation (\_ -> k x))) k)
<mrvn> Thats a call/cc for haskel using cps
Demitar has quit ["There are bubbles in the air..."]
<mrvn> The hard part is transforming all your code to cps.
<Riastradh> That's why the MonadCont monad is used -- it makes it much simpler.
<Vincenz> I've heard it's technically possible to write a tool that does it automatically cause the mapping is said to be very straight
<mrvn> most modern compilers do it
<Riastradh> Does the OCaml compiler do it?
<Vincenz> trying to bash ocaml?
<mrvn> If it does you don#t have access to it.
<mrvn> cps doesn#t realy mesh with ocamls stack I think.
<Riastradh> If it did, then a callcc would be very easy to define with it.
<mrvn> nah, once you have a stack call/cc becomes hard/expensive.
<Riastradh> If it did use CPS, I meant.
<mrvn> It still might use it as intermediat format
<Riastradh> It wouldn't have a stack if it used CPS.
<Riastradh> Either that or it would use it in a very clever way, like CHICKEN does.
lus|wazze has quit ["Weird Al Yankovic - Frank's 2000 Inch TV - 'cuz "everybody in the town can hear the 90.000 watts of dolby sound!""]
reltuk has quit ["Client exiting"]
mrvn_ has joined #ocaml
TachYon has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
TachYon has quit [Remote closed the connection]
__DL__ has quit [Remote closed the connection]
cDlm_ has joined #ocaml
cDlm has quit [Killed (NickServ (Ghost: cDlm_!cdlm@lns-th2-7-82-64-104-79.adsl.proxad.net))]
cDlm_ is now known as cDlm
systems has joined #ocaml
mrvn_ is now known as mrvn
systems has quit ["Client Exiting"]
<Vincenz> anyone know if it's possible to remove Sys and Filename from the toplevel?
<Vincenz> never mind :)
<Vincenz> easy
<Vincenz> just remove the files :P
<mrvn> Or create files with the same name yourself.
<Vincenz> but I'm just curious if it's still possible by the user to do anything
<Vincenz> like...let's say I wanted to make an online interpreter....I would not want him to do stuff to my system.
<mrvn> Should work
<mrvn> don#t forget the C files though.
cDlm_ has joined #ocaml
cDlm has quit [Killed (NickServ (Ghost: cDlm_!cdlm@lns-p19-19-82-65-128-49.adsl.proxad.net))]
<Vincenz> hmm, but they don't have access to my system, so what could they do with C files?
cDlm_ is now known as cDlm
<mrvn> They might define their own interface like Sys or Unix that uses those files.
<mrvn> Not unix though since its not included in the normal runtime.
<Vincenz> oh
<Vincenz> hmm
<mrvn> Just tyr to rebuild ocam without all the sys files or with a module making all Sys functions fail.
<Vincenz> I could modify the toplevel to not allow externals?
<mrvn> You have to disable Obj too. Otherwise you could execute user define assembler code.
<mrvn> And without Obj Buffer won#t work and marshaling.
TachYon has joined #ocaml
<mrvn> And Probably a few others too.
<Vincenz> hmm
<Vincenz> damn
<Vincenz> :/
<mrvn> I guess its easier to write your own Sys and Obj modules that shadow the original once and build anew toplevel with them.
<mrvn> s/once/ones/
<Vincenz> they could still use external...
<mrvn> hmm. Not sure if you can shadow external functions.
<Vincenz> that's the prob
<Vincenz> too bad :/
<mrvn> Might work with dynamic loading.
TachYon has quit ["Client Exiting"]
<Vincenz> night
Vincenz has quit ["Sleep"]
travisbemann has joined #ocaml
<travisbemann> i've got a major problem with finalization, threads, and GCing
<travisbemann> i've got all my datastructures in a program protected with mutexes, but because i'm basically using them to access remote objects with what is essentially an RPC interface, when a local object is garbage collected, the finalizer must tell the other end to free the handle for the given remote object
<travisbemann> but the problem is that because finalization may occur in any thread, i can't lock any mutexes in the actual finalization routine
<travisbemann> so i'm planning on having the finalizer just tell a reaper thread to go and reap the remote object
<travisbemann> but the problem is that how do i do that without getting race conditions (because i can't use mutexes to protect doing so)
<travisbemann> anyone have any clue
<travisbemann> ?
<travisbemann> well, forget that; solved that by making a separate reaper thread for each object to be reaped
__DL__ has joined #ocaml
__DL__ has quit [Client Quit]
systems has joined #ocaml
systems has quit [Read error: 60 (Operation timed out)]
travisbemann is now known as travis|away