Re: Mixing syntax-rule and indentifier-syntax

2012-01-18 Thread Andy Wingo
On Wed 18 Jan 2012 00:26, Tobias Brandt writes: >> 0. I'm sure there is another way, but my mind blanks at the moment > > After you got me started, I was able to simplify and generalize it a bit. > (-> is a GOOPS generic accessor I defined elsewhere. It works with > vectors, arrays, strings, etc

Re: Accessing multiple values from C

2012-01-18 Thread Andy Wingo
On Wed 18 Jan 2012 04:15, Mark H Weaver writes: > Should this verify that `obj' is a values object? > > Should it verify that `idx' can fit in an inum? Agreed! > Also, if `obj' is _not_ a values object and `idx' is 0, should this > simply return `obj'? Since a single value is conceptually no d

Re: Accessing multiple values from C

2012-01-18 Thread Ludovic Courtès
Hi Mark, Mark H Weaver skribis: > Julian Graham 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? > > Shoul

Re: Accessing multiple values from C

2012-01-18 Thread Julian Graham
Hi all, Thanks for the review! On Wed, Jan 18, 2012 at 3:19 PM, Ludovic Courtès wrote: > Julian: could you change these bits and send an updated patch? Will do. Regards, Julian

Re: Accessing multiple values from C

2012-01-18 Thread Mark H Weaver
l...@gnu.org (Ludovic Courtès) writes: > Mark H Weaver skribis: > >> Julian Graham 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 veri

Re: Accessing multiple values from C

2012-01-18 Thread Ludovic Courtès
Hi! Mark H Weaver skribis: > l...@gnu.org (Ludovic Courtès) writes: > >> Mark H Weaver skribis: >> >>> Julian Graham 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 (i

Re: Accessing multiple values from C

2012-01-18 Thread Mark H Weaver
I think something along these lines be ideal, though this code is UNTESTED. Mark SCM scm_c_value_ref (SCM obj, size_t idx) { if (SCM_VALUESP (obj)) { SCM values = scm_struct_ref (obj, SCM_INUM0); size_t i = idx; while (SCM_LIKELY (!scm_is_null (values))) {

Re: Accessing multiple values from C

2012-01-18 Thread Mark H Weaver
At Julian's request, I went ahead and pushed my implementation of `scm_c_value_ref' to the stable-2.0 branch, so it will be in 2.0.4. Thanks, Mark