xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@eu.citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Gianni Tedesco <gianni.tedesco@citrix.com>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: [PATCH 1 of 4] xl: idl: Abolish keyed union types
Date: Thu, 6 Jan 2011 18:55:37 +0000	[thread overview]
Message-ID: <1294340137.13733.58.camel@localhost.localdomain> (raw)
In-Reply-To: <19750.597.357993.810638@mariner.uk.xensource.com>

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.

  reply	other threads:[~2011-01-06 18:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05 13:41 [PATCH 0 of 4] Refactor libxl domain creation, v2 Gianni Tedesco
2011-01-05 13:41 ` [PATCH 1 of 4] xl: idl: Abolish keyed union types Gianni Tedesco
2011-01-06 17:56   ` Ian Jackson
2011-01-06 18:55     ` Ian Campbell [this message]
2011-01-07 13:09     ` Gianni Tedesco
2011-01-05 13:41 ` [PATCH 2 of 4] xl: Introduce libxl_domain_create_new() and libxl_domain_create_restore() Gianni Tedesco
2011-01-06 17:58   ` Ian Jackson
2011-01-06 19:34     ` Stefano Stabellini
2011-01-07 12:58       ` Gianni Tedesco
2011-01-05 13:41 ` [PATCH 3 of 4] xl: Move device model functions in to a separate file Gianni Tedesco
2011-01-06 18:00   ` [PATCH 3 of 4] xl: Move device model functions in to a separate file [and 1 more messages] Ian Jackson
2011-01-07 13:12     ` Gianni Tedesco
2011-01-07 15:43       ` Ian Jackson
2011-01-05 13:41 ` [PATCH 4 of 4] xl: Implement flexarray_append() and flexarray_vappend() Gianni Tedesco
2011-01-07 13:37   ` Gianni Tedesco

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=1294340137.13733.58.camel@localhost.localdomain \
    --to=ian.campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=gianni.tedesco@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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;
as well as URLs for NNTP newsgroup(s).