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

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 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
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 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 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 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-17 Thread Mark H Weaver
Hi Julian, thanks for working on this! 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? Should it verif

Re: Accessing multiple values from C

2012-01-16 Thread Andy Wingo
On Sun 15 Jan 2012 22:47, l...@gnu.org (Ludovic Courtès) writes: Not yet.  You interested in adding scm_c_value_ref (SCM, size_t) to the API, and documentation to api-control.texi?  If you do it soon, it will make it into 2.0.4. >>> >>> Sure.  Gimme a day or so and I'll have somethi

Re: Accessing multiple values from C

2012-01-16 Thread Ludovic Courtès
Hi Julian, Julian Graham skribis: >>> Not yet.  You interested in adding scm_c_value_ref (SCM, size_t) to the >>> API, and documentation to api-control.texi?  If you do it soon, it >>> will make it into 2.0.4. >> >> Sure.  Gimme a day or so and I'll have something for review. > > Find attached a

Re: Accessing multiple values from C

2012-01-11 Thread Julian Graham
Howdy, >> Not yet.  You interested in adding scm_c_value_ref (SCM, size_t) to the >> API, and documentation to api-control.texi?  If you do it soon, it >> will make it into 2.0.4. > > Sure.  Gimme a day or so and I'll have something for review. Find attached a patch. Let me know if I missed any

Re: Accessing multiple values from C

2012-01-09 Thread Julian Graham
Hey Andy, > Not yet.  You interested in adding scm_c_value_ref (SCM, size_t) to the > API, and documentation to api-control.texi?  If you do it soon, it > will make it into 2.0.4. Sure. Gimme a day or so and I'll have something for review. Regards, Julian

Re: Accessing multiple values from C

2012-01-09 Thread Andy Wingo
Hi, On Tue 01 Nov 2011 16:34, Julian Graham writes: > I was playing around with some C code that uses the new R6RS > bytevector ports, and I noticed that there doesn't seem to be an easy > way (a la `let-values' or `receive') to access multiple return values > from C. I've resorted to doing: >

Re: Accessing multiple values from C

2011-11-01 Thread Ludovic Courtès
Hi, Julian Graham skribis: > I was playing around with some C code that uses the new R6RS > bytevector ports, and I noticed that there doesn't seem to be an easy > way (a la `let-values' or `receive') to access multiple return values > from C. I've resorted to doing: > > scm_struct_ref (foo,

Accessing multiple values from C

2011-11-01 Thread Julian Graham
Hey all, I was playing around with some C code that uses the new R6RS bytevector ports, and I noticed that there doesn't seem to be an easy way (a la `let-values' or `receive') to access multiple return values from C. I've resorted to doing: scm_struct_ref (foo, SCM_INUM0); ...which is almost