caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Some, None and the caml-C interface
@ 2003-01-09  2:54 Yaron M. Minsky
  2003-01-10 17:17 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Yaron M. Minsky @ 2003-01-09  2:54 UTC (permalink / raw)
  To: Caml List

I've written some simple macros for accessing options in ocaml, and I
want to double check that they are actually right.  Does this look
right?  And is this documented anywhere?

#define Is_None(v)  (Is_long(v))
#define Is_Some(v)  (!Is_None(v))
#define Some_val(v) (Field(v,0))

Thanks,
Yaron

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Some, None and the caml-C interface
  2003-01-09  2:54 [Caml-list] Some, None and the caml-C interface Yaron M. Minsky
@ 2003-01-10 17:17 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2003-01-10 17:17 UTC (permalink / raw)
  To: Yaron M. Minsky; +Cc: Caml List

> I've written some simple macros for accessing options in ocaml, and I
> want to double check that they are actually right.  Does this look
> right?

Yes, it is.

> And is this documented anywhere?

The general representation of sum datatypes is described in section
18.3.4 of the OCaml manual.  If you "instantiate" this description to
the actual definition of type option
        type 'a option = None | Some of 'a
you can derive the macros that you posted.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-10 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-09  2:54 [Caml-list] Some, None and the caml-C interface Yaron M. Minsky
2003-01-10 17:17 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).