xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: Nicholas Rosbrook <rosbrookn@ainfosec.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "anthony.perard@citrix.com" <anthony.perard@citrix.com>,
	Brendan Kerrigan <kerriganb@ainfosec.com>,
	"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
	Nicolas Belouin <nicolas.belouin@gandi.net>,
	"wl@xen.org" <wl@xen.org>
Subject: Re: [Xen-devel] [RFC] Generating Go bindings for libxl
Date: Fri, 13 Sep 2019 12:21:13 +0100	[thread overview]
Message-ID: <4ebed087-27b6-c473-6bca-487e2bf85381@citrix.com> (raw)
In-Reply-To: <1be9800ff98f4cff82a72e747286f5f5@ainfosec.com>

On 9/12/19 6:35 PM, Nicholas Rosbrook wrote:
> I'm not strongly opposed to the struct duplication, but I do prefer the ability
> to perform type assertions as a way to determine which field is "valid."

Fair enough.

>> So the advantage of this is that you can just call:
>>
>>     fromC(&di, &cdi)
>>
>> Rather than:
>>
>>     di.fromC(&cdi)
>>
>> ?
>>
>> But the cost for this is that we're switching from static type-checking
>> to dynamic type-checking.  If in the first example, cdi is the wrong
>> type (for instance, if we forget the & at the front), everything will
>> compile, and we won't notice unless the function actually gets called.
>> In the second example, if we're not trying to implement a generic
>> "marshaler" method, we can define the function signature to specify
>> exactly what pointer we need.
> 
> The advantage is it simplifies the generated code's error handling. However,
> I was re-thinking this portion as well, because giving up the static type
> checking is not worth "cleaner" generated code. I'll make that change.

Ah, right the main purpose was to have the single place at top to catch
 exceptions^W^W recover from panics, not so much because one form of the
function was nicer than the other one.  Still, I think static type
checking is a big thing to give up to make generated code cleaner.  Thanks.

>> I'd be tempted to say just do something like:
>>
>> type CpuidPolicyList struct {
>>     val C.libxl_cpuid_policy_list
>> };
>>
>> A part of me thinks even something like this wouldn't be terrible:
>>
>> type CpuidPolicyList C.libxl_cpuid_policy_list
>>
>> It "leaks" the internals out to the callers, but it also means you don't
>> have to do all this faff of marshalling / unmarshalling what's
>> essentially just a pointer.
> 
> I don't think it's a good idea to expose the C type. Besides the fact that [2]
> explicitly states not to do this, exporting this type gives the false idea that
> this type is somehow portable.

Ack.

>> It sort of looks like this is an entirely internal thing that libxl
>> uses.  I think to begin with we can just declare this as an empty
>> struct, and figure out what to put in it once it becomes more clear how
>> it needs to be used.
> 
> Okay, will do.

FWIW checked with Ian after I wrote this mail, and he confirmed that
that field (`link` in `libxl_event`) was only meant to be used
internally, and ideally we wouldn't even have that available in the Go
version of the struct (since it's not actually part of the public
interface).

Unfortunately we can't actually get rid of the element it without
special-casing it (which I don't think is a good idea), or adding a new
"PRIVATE()" annotation to the IDL or something (which would be nice to
have, but not something I expect anyone to have much time to do).  For
now, I think defining it as an empty struct will be good enough.

Great, thanks!  Look forward to the next iteration!

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-09-13 11:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 13:11 [Xen-devel] [RFC] Generating Go bindings for libxl Nicholas Rosbrook
2019-07-30 13:48 ` Tamas K Lengyel
2019-07-30 15:49   ` George Dunlap
2019-07-30 18:39     ` Tamas K Lengyel
2019-07-31 15:14       ` George Dunlap
2019-07-30 15:22 ` George Dunlap
2019-07-30 21:52   ` Nicholas Rosbrook
2019-07-31 15:06     ` George Dunlap
2019-07-31 21:22       ` Nicholas Rosbrook
2019-08-01 18:59         ` Nicholas Rosbrook
2019-08-02 15:38           ` George Dunlap
2019-08-02 19:09             ` Nicholas Rosbrook
2019-09-04  0:36             ` Nicholas Rosbrook
2019-09-04 16:52               ` George Dunlap
2019-09-04 16:59                 ` George Dunlap
2019-09-04 18:23                   ` Nicholas Rosbrook
2019-09-11 20:25                   ` Nicholas Rosbrook
2019-09-12 14:37                     ` George Dunlap
2019-09-12 17:35                       ` Nicholas Rosbrook
2019-09-13 11:21                         ` George Dunlap [this message]
2019-09-13 13:28                           ` Nicholas Rosbrook
2019-09-24  0:33                           ` Nicholas Rosbrook
2019-09-30 14:51                             ` George Dunlap
2019-09-30 18:08                               ` Nicholas Rosbrook
2019-09-04 18:15                 ` Nicholas Rosbrook
2019-08-02 15:55         ` George Dunlap
2019-07-30 16:27 ` George Dunlap

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=4ebed087-27b6-c473-6bca-487e2bf85381@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=kerriganb@ainfosec.com \
    --cc=nicolas.belouin@gandi.net \
    --cc=rosbrookn@ainfosec.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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).