Any potential infrastructure related projects or experiments?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Apr 26 16:50:12 UTC 2022
On Tue, Apr 26, 2022 at 04:04:25PM +0000, ryuukk_ via Digitalmars-d wrote:
[...]
> My wishlist:
[...]
> - builtin tagged union
There's already std.variant.Variant, and one or two dub packages that do
similar things.
> - builtin multiple return type
std.typecons.Tuple does an OK job of it (just return `Tuple!(int,
string)`, for example). It's also pretty easy to write your own
template for doing this in just a few of lines of code:
struct MultiRet(T...) {
T values;
alias values this;
}
auto multiRet(T...)(T values) {
return MultiRet!T(values);
}
auto myFunc() {
return multiRet(10, "string", 3.14159);
static assert(is(typeof(return) == MultiRet!(int,
string, double)));
}
auto values = myFunc();
assert(values[0] == 10);
assert(values[1] == "string");
assert(values[2] == 3.14159);
T
--
He who sacrifices functionality for ease of use, loses both and deserves neither. -- Slashdotter
More information about the Digitalmars-d
mailing list