
Language support for functions that return multiple values - jsnell
http://arcanesentiment.blogspot.com/2016/01/many-happy-returns.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+ArcaneSentiment+(Arcane+Sentiment)
======
prestonbriggs
I've always liked Beta's approach to assignment, calls, and returns (whilst
disliking most of the rest of its syntax, sigh).

Assignments work left to right, approximately like this:

    
    
        (x, y) => (y, x)
    

which swaps x and y.

Calls that return multiple values look like

    
    
        x => sincos => (sinx, siny)
    

and we can string together all sorts of things like this

    
    
        x => sincos => sum => y
    

Procedures looked something like

    
    
        sincos(double x) {
          ...
        } returns (sinval, cosval)
    

All this syntax is pretty approximate, but perhaps you'll get the idea. To me,
it seemed attractive in that a tuple of values flowed in at the top of a
procedure, then left to right on each line, and top to bottom between lines,
and finally a tuple of values is returned. Seemed like a natural sugaring of
CPS style.

------
gsg
The two-continuation style suggested there is familiar to me under the name
"double barreled CPS", although usually in the context of compilation.
Interesting to see it suggested for user code.

------
frozenport
Returning multiple values is not atomic.

~~~
tomcam
Pray explain further?

