Version française
Home     About     Download     Resources     Contact us    
Browse thread
A copy/paste buffer
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Le Normand <rathereasy@g...>
Subject: A copy/paste buffer
Hello caml-list,
I want to implement a copy/paste buffer for arbitrary polymorphic variants.
Is the following code safe?


"
let buffer  : 'a = Obj.magic (ref None)

let _ = buffer := Some `Foo
let _ = buffer := Some `Bar

let _ =
  match !buffer with
      Some (`Bar x) -> print_endline "matches"
    | _ -> ()
"


also, how would I refine the buffer type a little more? Every time I try, I
run into the value restriction
cheers
--Jacques L.