Version française
Home     About     Download     Resources     Contact us    
Browse thread
Limitations of continuation?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Limitations of continuation?
Xavier Leroy wrote a small continuation proof of concept module which
can be found here:
http://pauillac.inria.fr/~xleroy/software.html

I've been toying with it lately whilst doing so I stumbled across a problem:

I'm using a module containing the following code:

let continuation_to_string k =
  let c=Marshal.to_string k [Marshal.Closures] in
  Netencoding.Base64.encode ~linelength:72 c

let send_page (f:string->unit) =
  let apply f k=
    f (continuation_to_string k)
  in
  Callcc.callcc(apply f)

let _ =
  try (
    let cgi = new Netcgi.std_activation () in
    let res = (
      let cont=(cgi#argument "continuation") # value in
      Netencoding.Base64.decode ~accept_spaces:true cont
    ) in
    let k=Marshal.from_string res 0 in
    Callcc.throw k ())
  with Not_found -> ()

I have a test app using this module. If I compile it with a standard
Open ... the code segfaults, however if I inline the code (i.e. not
actually putting it in a separate file) the application works just
fine. I guess the compiler builds different code since it is working
with modules. Where those this come from and would there be anyways to
work around it ?

Regards,
Till