Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Language support for functions that return multiple values (arcanesentiment.blogspot.com)
26 points by jsnell on Jan 11, 2016 | hide | past | favorite | 4 comments


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.


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.


Returning multiple values is not atomic.


Pray explain further?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: