Chaining Return Types

Something that bothers me about C is that it doesn't let you write chaining void returns:

void my_function() {
    return some_void_function(...);  /* this is not legal! */
}

That annoys me, because it makes it hard to write generic code that doesn't want the bad properties of a macro (repeating evaluation of arguments if used multiple times, etc.)...but throws a wrench in being able to abstract across return values.

But Ren-C has this covered! All states can be chained.

But what if you are writing a wrapped function, and want a type signature on the wrapper that matches what you are wrapping? I guess we could do this via COMPOSE on the spec of some kind:

my-function: func compose [
    return: (return-type-block-of :some-other-function)
    ...
][
    ...
    return some-other-function ...
]

Something along these lines, where you could add or remove elements of the type signature. :-/Anyway, I just wanted to mention that we're not yet at utopia in this medium, even if we're pretty much nailing the chaining part itself!

This is now possible, via RETURN OF!

my-function: func compose [
    return: (return of some-other-function/)
...
][
    ...
    return some-other-function ...
]

It's pretty darn good. :slight_smile: But it does need some work on letting you do composition or surgery.

RETURN OF gives you a PARAMETER!, which encodes a string description, a spec block, what meta-convention or optionality via refinement it has, etc...

So you could say (return of some-other-function/).spec to get the spec block and manipulate that.

We could add RETURN:SPEC OF or some other way of just getting the block. Then you could JOIN in another type you wanted to add more easily. But you'd lose the description.

Anyway, it's coming along!