Well, our language is very much at the dynamic end of things, so functions can return an object or tuple of objects and the caller may want an object or a tuple. When we create a call site we install a result filter that checks the required and returned types and (un)packs as necessary. Obviously this isn't applicable to normal Java code, and can be short circuited in a large number of cases where a function ends up returning the result of another function.
You can't really get round the fact that a function has to return a single value, and you'll need to unpack that (and you can't do it in a loop obviously because of the stack map), from our tests a result tuple consisting of a final Object[] array, an int index counter, and pop() and popAll() methods worked best, but if you know the structure of your tuples in advance then you may be able to do better. On 09/01/2013 17:52, "Dain Sundstrom" <d...@iq80.com> wrote: >Hi all, > >I'm working on a small, simple, statically-typed language which has >primitive data types and simple single-level structs. For example an ip6 >address is a struct of two longs. For the vast majority of code, I can >represent the structs directly on the stack or in slots as primitives. >The obvious issue is, how do I efficiently return a struct from a >function? So how is everyone else dealing with multi-return (and does >your technique work in existing Java7)? > >Thanks, > >-dain >_______________________________________________ >mlvm-dev mailing list >mlvm-dev@openjdk.java.net >http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev _______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev