From: Richard Jones <rich@annexia.org>
To: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Wrapping var_args, or C ... in ocaml?
Date: Sun, 14 Feb 2010 22:59:31 +0000 [thread overview]
Message-ID: <20100214225931.GC24949@annexia.org> (raw)
In-Reply-To: <4B787D32.10505@citycable.ch>
On Sun, Feb 14, 2010 at 11:46:10PM +0100, Guillaume Yziquel wrote:
> Not the case.
[etc]
It would help if you were to be more specific about the function that
you're trying to bind.
> But, I mean, from the point of view of the ABI, there's not much
> trickery in the concept. It looks that it is C that is not mapping the
> concept to its fullest potential.
>
> I mean, it seems that varargs means on the receiving end "the number of
> arguments you'r giving me, as a function, is not limited", whereas on
> the sending end, you hard-code the number of arguments in your C code.
In the C case the sender pushes arguments right to left on the stack,
and the receiver must deduce in an unspecified way how many arguments
were pushed. This can be because the sender promises to
NULL-terminate the list, or encodes in an earlier argument some
indication of how many arguments follow, or they might even have given
it in a previous function call, or have just agreed it in the
documentation.
If the receiver gets it wrong, there is plenty of scope for
catastrophic errors to occur -- and this is not merely a theoretical
problem, but a very real problem that many C programmers have
encountered. So I'm quite happy that OCaml doesn't make this kind of
poorly-specified function easy to implement.
> Is there a way to map an OCaml list to an ellipsis? Or is it a C
> limitation?
I'm not sure exactly what this means. An OCaml list is a
well-defined, well-typed version of the C ellipsis isn't it?
Rich.
--
Richard Jones
Red Hat
next prev parent reply other threads:[~2010-02-14 22:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-14 15:46 Guillaume Yziquel
2010-02-14 18:06 ` [Caml-list] " Richard Jones
2010-02-14 20:26 ` Richard Jones
2010-02-14 22:46 ` Guillaume Yziquel
2010-02-14 22:59 ` Richard Jones [this message]
2010-02-14 23:13 ` Guillaume Yziquel
2010-02-14 23:19 ` Richard Jones
2010-02-15 1:34 ` Guillaume Yziquel
2010-02-15 2:37 ` Thomas Fischbacher
2010-02-14 23:31 ` Richard Jones
2010-02-15 10:16 ` Florent Monnier
[not found] ` <201002151106.23642.fmonnier@linux-nantes.fr.eu.org>
[not found] ` <4B7F3FED.4010100@citycable.ch>
2010-02-20 2:41 ` Guillaume Yziquel
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=20100214225931.GC24949@annexia.org \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
--cc=guillaume.yziquel@citycable.ch \
/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