Email or username:

Password:

Forgot your password?
Andrew Tropin

Is there is a good reason to have multi-value return in #Scheme? It seems returning a vector does the trick quite well. Am I missing something?

7 comments
Tom :emacs: :guix:

@abcdw the only thing I can think of right now is just being explicit about it. Returning a vector doesn't help anyone understand that the vector is of a fixed length, or technically a tuple.

oh actually I guess one thing I like about the ability to do it in Common Lisp is that unless you explicitly need the other return values you just get the first one. Although I guess that could be seen as a downside too.

anyway, that's just my speculation and opinion, I don't usually need or want it.

Andrew Tropin

@ryuslash Thank you for sharing your thoughts on the topic, make sense.

The shape of data could be a part of function metadata. Also, I heard multiple return values is somehow related to continuations. Will need to learn more about it.

Tom :emacs: :guix:

@abcdw Oh really? Dang continuations still escape me. I think I kinda have the basic idea down, but I can't visualize it, I can't reason about what the execution flow is like yet...

I'm curious now to know how multiple return values is related to continuations.

Andrew Kravchuk

@abcdw I think this generally might be related to low-level optimization, like compiler being able to spill mutliple values into registers, as opposed to vector, which should be honest-to-god allocated in heap (or on stack).

Go Up