Lokesh Setia <lsetia@lsetia.hss.hns.com> wrote:
+---------------
| Say, I have to implement a function in C for use with guile which has
| to return values through its parameters.
+---------------
Not a good idea.
+---------------
| (c-func val1 val2 val3 'result1 'result2)
| The user passes some values in val1, val2, val3, and gets the answers
| in symbols result1 and result2.
| Of course, I could have designed the function such that the user will
| have to say:
|
| (set! result (c-func val1 val2 val3))
| (set! result1 (car result))
| (set! result2 (cdr result))
+---------------
Dunno 'bout Guile, but C code called from MzScheme can return R5RS
multiple values, so the clean way is:
(call-with-values
(lambda () (c-func val1 val2 val3))
(lambda (result1 result2)
...code that uses results 1 & 2...
))
or at the top level:
(define-values (result1 result2) (c-func val1 val2 val3))
or if you insist on doing a "set!":
(set!-values (result1 result2) (c-func val1 val2 val3))
-Rob
-----
Rob Warnock, 41L-955 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. PP-ASEL-IA
Mountain View, CA 94043