Skip to content

Instantly share code, notes, and snippets.

@avsm
Created May 21, 2011 01:29
Show Gist options
  • Save avsm/984125 to your computer and use it in GitHub Desktop.
Save avsm/984125 to your computer and use it in GitHub Desktop.
delimcc fragment that seems to fail on ocamlopt but work in ocamlc
open Printf
open Delimcc
let p = new_prompt ()
let main () =
let kr = ref (fun _ -> ()) in
push_prompt p (fun () ->
let foo = 15 in
let bar = foo +
shift0 p (fun k ->
kr := k;
) in
printf "res %d\n%!" bar;
);
!kr
let _ =
let k = main () in
k 10;
k 15;
let oc = open_out "foo" in
output_delim_value oc k;
close_out oc
let _ =
let ic = open_in "foo" in
let (k : int -> unit) = Marshal.from_channel ic in
k 20;
k 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment