# Multiple values with Racket behave different than Guile or Chicken

**URL:** <https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667>\
**Category:** General\
**Created:** [January 27, 2023, 9:58am UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667 "2023-01-27T09:58:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [January 27, 2023, 9:58am UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/1 "2023-01-27T09:58:43Z")

</div>

hello,

it is for a while i did not use 'values in Scheme and i did not use often 'values (so i perhaps have a problem of comprehension with 'values) and doing this in Racket with racket language or R5RS give the same error:

Welcome to DrRacket, version 8.6 [cs].  
Language: R5RS; memory limit: 14000 MB.

> (+ 1 2 (values 3 4) 5)  
> . . result arity mismatch;  
> expected number of values not received  
> expected: 1  
> received: 2

instead with Guile or Chicken it works:

CHICKEN  
(c) 2008-2019, The CHICKEN Team  
(c) 2000-2007, Felix L. Winkelmann  
Version 5.1.0 (rev 8e62f718)  
linux-unix-gnu-x86-64 [64bit dload ptables]  
#;2\> (+ 1 2 (values 3 4) 5)  
11

GNU Guile 3.0.1  
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details.

Enter `,help' for help.  
scheme@(guile-user)\> (+ 1 2 (values 3 4) 5)  
11

???

what is the good behavior? am i missing something??

Regards,  
Damien

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [January 27, 2023, 2:27pm UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/2 "2023-01-27T14:27:54Z")

</div>

Note that `(+ 1 2 3 4 5)` yields 15; Guile and Chicken drop the 4.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [January 27, 2023, 3:23pm UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/3 "2023-01-27T15:23:10Z")

</div>

yes i noticed it later.  
In fact 'values are not of a great help for what i'm doing.  
I'm doing an infix evaluator and i'm sticked to other problems... but thank for your remark.

---

<div class="post-metadata">

**Author:** ![gus-massa](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/gus-massa/32/507_2.png) [@gus-massa](https://racket.discourse.group/u/gus-massa)\
**Post date:** [January 27, 2023, 8:02pm UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/4 "2023-01-27T20:02:07Z")

</div>

This is about R5RS. I can't find the R6RS one [https://man.scheme.org/values.3scheme](https://man.scheme.org/values.3scheme)

> IMPLEMENTATION NOTES  
> Implementations vary greatly in how they treat multiple values that are returned to single-value continuations. Portable programs should not rely on any of these behaviors.  
> [List of implementation details]

So ... everyone is correct.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [January 27, 2023, 9:36pm UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/5 "2023-01-27T21:36:13Z")

</div>

> [@damien\_mattei](#):
>
> GNU Guile 3.0.1  
> Copyright (C) 1995-2020 Free Software Foundation, Inc.
> 
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details.
> 
> Enter `,help' for help.  
> scheme@(guile-user)\> (+ 1 2 (values 3 4) 5)  
> 11

While this does currently work in Guile, beware that the behavior you are relying on is explicitly not guaranteed. In the documentation for `values`, the [Guile reference manual](https://www.gnu.org/software/guile/manual/html_node/Multiple-Values.html) states:

> The effect of passing no value or more than one value to continuations that were not created by `call-with-values` is unspecified.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [January 28, 2023, 9:25am UTC](https://racket.discourse.group/t/multiple-values-with-racket-behave-different-than-guile-or-chicken/1667/6 "2023-01-28T09:25:20Z")

</div>

yes  
call-with-values is used in my code (not me that wrote this piece of code) but it is not easy to use, it is in my code hidden behind macros,so 'values are more transparent for users.  
example using my \<v operator that assign multiple values on the fly:

```scheme
(define T (make-vector 5))
{(x {T[4]} z) <v (values 1 2 3)}

```

A bit like in Python when you assign a triplet with multiple values like that:

> (x,y,z) = (1,2,3)

using infix evaluation , i'm implementing precedente in infix parsing that could remove a few more {} curly brackets.

of course this is only an example, the RHS expression in code is a procedure call returning multiple values like in this example:

`{(x y) ⥆ (to-screen-multi-values z)}`

> <https://github.com/damien-mattei/Scheme-PLUS-for-Racket/blob/main/examples/zeta%2B.rkt#L49>

example at end of this page also:

> **[\[“Scheme+ programing language by Damien Mattei”\]](https://damien-mattei.github.io/Scheme-PLUS-for-Racket/Scheme+io.html)**
>
> \[“Enhancing Scheme (and Lisp-like) languages.”\]

here the \<+ or ⥆ create definitions (\<v doing only assignation of previously existing variable)

this lead me to another problem i have with evaluation of quoted variables in the Racket envionment using namespaces, i do not know where to define the namespace to have variables evaluated from any place in the code with the infix evaluator but i will open another thread as this is another problem.

Damien
