Multiple values with Racket behave different than Guile or Chicken

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

1 Like

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

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.

This is about R5RS. I can't find the R6RS one 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.

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 states:

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

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:

(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)}

example at end of this page also:

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