Hi! Mark H Weaver <m...@netris.org> skribis:
> l...@gnu.org (Ludovic Courtès) writes: > >> Mark H Weaver <m...@netris.org> skribis: >> >>> Julian Graham <jool...@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’.