Thank you for reminding me that, while Python is slow, there are still reasons to pick it over the alternatives.
typedef struct {
double d;
int err;
} Ret;
Ret foo(void) {
Ret r = { 0.0, 43};
return r;
}
int main() {
Ret r = foo();
}
You can't return a bare fixed-size array though. foo, bar = compute_foo_and_bar()
If you don't care about ergonomics, then sure, C and Java are turing complete so there's always a way to get values where you need them, albeit with a few extra lines of code. FooAndBar foo_and_bar = compute_foo_and_bar();
Foo foo = foo_and_bar.foo;
Bar bar = foo_and_bar.bar; switch(computeFooAndBar()) {
case Result(var foo, var bar) -> System.out.println("one case");
default -> System.out.println("Something else");
}
-- https://godbolt.org/z/369cfbEv1