unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: Andy Wingo <wingo@pobox.com>, Guile Users <guile-user@gnu.org>
Subject: Re: Accessing multiple values from C
Date: Wed, 18 Jan 2012 22:44:39 +0100	[thread overview]
Message-ID: <87ty3ssn20.fsf@gnu.org> (raw)
In-Reply-To: <87sjjcybc6.fsf@netris.org> (Mark H. Weaver's message of "Wed, 18 Jan 2012 16:01:13 -0500")

Hi!

Mark H Weaver <mhw@netris.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Mark H Weaver <mhw@netris.org> skribis:
>>
>>> Julian Graham <joolean@gmail.com> writes:
>>>> +SCM
>>>> +scm_c_value_ref (SCM obj, size_t idx)
>>>> +{
>>>> +  SCM values = scm_struct_ref (obj, SCM_INUM0);
>>>> +  return scm_list_ref (values, SCM_I_MAKINUM (idx));
>>>> +}
>>>> +
>>>
>>> Should this verify that `obj' is a values object?
>>>
>>> Should it verify that `idx' can fit in an inum?
>>
>> Yes, good point.  Using an ‘SCM_VALIDATE’, which will throw an exception
>> upon error, right?
>
> Well, there's a complication with using an `SCM_VALIDATE' to check for
> values objects.  If `idx' is 0 (make sure it's exact!), then we must
> _not_ throw an exception if `obj' is not a values object.  However, in
> that case we still need to know whether `obj' is a values object or not.

Yes, I already agreed on this one.  ;-)

> Also, a fine point about desirable error messages: asking for `idx' 5 of
> a values object with only 3 elements is, conceptually, the same kind of
> error as asking for `idx' 5 of something that is _not_ a values object.
>
> Therefore, I think in both cases the error should be something to the
> effect of "too few values".

Right.

Ludo’.



  reply	other threads:[~2012-01-18 21:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 15:34 Accessing multiple values from C Julian Graham
2011-11-01 22:57 ` Ludovic Courtès
2012-01-09 18:54 ` Andy Wingo
2012-01-09 19:00   ` Julian Graham
2012-01-12  4:50     ` Julian Graham
2012-01-15 21:47       ` Ludovic Courtès
2012-01-16  9:05         ` Andy Wingo
2012-01-18  3:15       ` Mark H Weaver
2012-01-18 16:20         ` Andy Wingo
2012-01-18 20:19         ` Ludovic Courtès
2012-01-18 21:01           ` Mark H Weaver
2012-01-18 21:44             ` Ludovic Courtès [this message]
2012-01-18 21:47             ` Mark H Weaver
2012-01-18 23:06               ` Mark H Weaver
2012-01-18 21:01           ` Julian Graham

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ty3ssn20.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.org \
    --cc=wingo@pobox.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 read-only IMAP folder(s) and NNTP newsgroup(s).