[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2-resend 08/30] libxl: ocaml: support for KeyedUnion in the bindings generator.



> You didn't quote this part ;-)
> 
> > ]     We generate C:
> > ]
> > ]     enum { FOO, BAR } foo;
> 
> I meant "enum foo { BAR, BAZ };" here.

I'll update the commit message.

> > So we generate
> >     type blargle__union = Bar of blargle_bar | Baz; ?  If this is
> > legal ocaml syntax, then fine, I guess.
> 
> Not just legal but idiomatic too, I think.
> 
> > (I can't remember what "of" does here.)
> 
> I'm not sure what the proper name would be (a KeyedUnion maybe ;-)) it
> means you can unpick it with:
> 
> match a_blargle with
>  | Bar of thing -> do stuff with the content of thing  | Baz -> do other 
> stuff,
> not with thing

That's right. It is called a "variant type" in OCaml, and it is typically 
unpacked by pattern matching.
See http://caml.inria.fr/pub/docs/manual-ocaml/manual003.html#s:tut-recvariants.

Cheers,
Rob

> (modulo me not remembering the real syntax, but it's close)
> 
> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.