Re: Asking introspection Lassi Kortela 11 May 2020 09:25 UTC

> Gauche has values->list and values-ref.   It is indeed handy.
> However, it's a bit difficult to make those primitives cover the
> necessary situations.
> Suppose you want to branch by the number of values yielded by EXPR.
>     (if (= (values-length EXPR) 1)
>        (let ((val EXPR))   ;; fast path
>           ...)
>        (let ((vals (values->list EXPR))) ;; generic path
>           ...))
> You have to evaluate EXPR twice.   If you want to make it evaluate once,
> you have to reify it
> in some way, which defeats the original motivation to write this kind of
> code.

The case-receive (by analogy to case-lambda) proposed by Marc solves
this nicely.