The language I am working on allows multiple return values from a function:
def myfunc() -> (int, String);
let a, b = myfunc();
I can think of two ways to implement this:
1) Return one of the values as the actual return value of the function, and quietly convert the rest to reference arguments.
2) Define a temporary, anonymous struct and return it.
Which approach is likely to be more efficient, or is there a better approach available?
The language I am working on allows multiple return values from a function:
def myfunc() -> (int, String);
let a, b = myfunc();
I can think of two ways to implement this:
We're currently working on first class support for multiple return values in the LLVM IR. The goal is to improve our x86-64 ABI compatibility, but it will have the side effect of allowing anyone to use it if they want it :). We're hoping this will be done for llvm 2.3 (~3 months or so from now).
1) Return one of the values as the actual return value of the function,
and quietly convert the rest to reference arguments.
2) Define a temporary, anonymous struct and return it.
Which approach is likely to be more efficient, or is there a better
approach available?
#2 is the same as #1, because you can't return structs by-value from functions in llvm: they are returned through a hidden pointer argument. Either way is reasonable until we get first class support for multiple return values.