WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 1 of 4] xl: idl: Abolish keyed union types

On Thu, 2011-01-06 at 17:56 +0000, Ian Jackson wrote: 
> Gianni Tedesco writes ("[Xen-devel] [PATCH 1 of 4] xl: idl: Abolish keyed 
> union types"):
> > xl: idl: Abolish keyed union types
> > 
> > Since the IDL file has become useful for generating language
> > bindings it has become apparent that the KeyedUnion type has no
> > straightforward translation to scripting languages which have no
> > notion of unions.
> 
> Uhh?  Most scripting languages' aggregate types are practically
> nothing _but_ unions!
> 
> The correct translation of a keyed union would probably be an
> aggregate (eg, in Python, a dictionary) containing an entry for the
> key and entries for whatever version of the union it involved.

The union type ends up looking quite nice in the ocaml bindings too:

        type build_spec = BuildHVM of build_hvm_info | BuildPV of build_pv_info

which allows nice ocaml idiomatic stuff like
        match build with
        | BuildHVM hvm -> do_some_hvm_stuff hvm
        | BuildPV pv -> do_some_pv_stuff pv

> > Turns out this is only used in domain_build_info which is hardly a memory
> > criticial structure.
> 
> However I don't have a strong opinion about the desirability of using
> a tagged union for this particular structure.

Me neither.

That ocaml stuff currently hand coded (and no one is imminently working
on changing that to my knowledge) so I don't think the libxl API change
arising from this IDL change prevents retaining this interface but it
does suggest why having the notion of a key which selects between
alternative fields could be a semantically useful concept in the
interface.

If having KeyedStruct instead of KeyedUnion simplifies things that could
be an alternative. Or go the whole hog and define a Dict type (turns
into an enum + the relevant number of fields)? Or just nuke it and cross
the bridge when we come to it ;-).

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel