Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques Le Normand <rathereasy@gmail.com>
To: caml-list caml-list <caml-list@yquem.inria.fr>
Subject: A copy/paste buffer
Date: Fri, 26 Jun 2009 01:44:24 -0400	[thread overview]
Message-ID: <f74178430906252244p2cd98854nb2395f7c438be2a8@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 444 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 546 bytes --]

                 reply	other threads:[~2009-06-26  5:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f74178430906252244p2cd98854nb2395f7c438be2a8@mail.gmail.com \
    --to=rathereasy@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox