Re: Number of return values of topological-sort
Lassi Kortela 01 Jul 2024 12:31 UTC
Shiro:
> Does topological-sort always return 3 values? I'm not sure because the second and third paragraph of the topological-sort entry seems to allow it to return either 1 or 3 values.
>
> I prefer not to have that choice; if it returns 3 values, all implementations should return 3 values. If that's the intention, we can state "It returns three values. The first value is the list of topologically sorted nodes or #f ..." to be clear.
+1
Shiro:
> "Optional return values" works in CL, where excessive return values are silently ignored, but that's not the case in Scheme.
Maxime:
> I sometimes find a variable number of return values to be
> convenient, but it’s very situation-dependent. (I’m not familiar
> enough with this situation in particular.)
I'm not aware of any Lisp dialect where returning a different number of
values from the same procedure is considered idiomatic.
When different callers bind a different number of values, that's
idiomatic in CL. But all expressions in the CL spec return a predictable
number of values.
Marc:
> There is still a difference to CL because you have to use one of the few
> keywords/procedures for multiple values in Scheme, while you would be
> able to use an analogous procedure in CL wherever a single value is
> expected.
>
> In any case, returning a varying number of values seems very
> non-idiomatic for typical Scheme code/APIs.
+1