guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing multiple values from C


From: Mark H Weaver
Subject: Re: Accessing multiple values from C
Date: Wed, 18 Jan 2012 16:01:13 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

address@hidden (Ludovic Courtès) writes:

> Mark H Weaver <address@hidden> skribis:
>
>> Julian Graham <address@hidden> 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.

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".

    Thanks,
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]