On 13 March 2012 16:44, Andrei Alexandrescu <seewebsiteforem...@erdani.org>wrote:
> I thought more about it and we should be fine with two functions > (untested): > > enum Skip {}; > @property ref Skip skip() { > static __gshared Skip result; > return result; > } > > void scatter(T, U...)(auto ref T source, ref U targets) { > assert(source.length == targets.length); > foreach (i, ref target; targets) { > static if (is(typeof(target) != Skip)) { > target = source[i]; > } > } > } > > void gather(T, U...)(ref T target, auto ref U sources) { > assert(target.length == sources.length); > foreach (i, source; sources) { > static if (is(typeof(source) != Skip)) { > target[i] = source; > } > } > } > > Usage: > > auto t = tuple(1, "hi", 2.3); > int a; > string b; > double c; > t.scatter(a, b, skip); // assigns a and b from tuple > b = "!"; > ++c; > t.gather(skip, b, c); // assigns tuple from variables b and c Well, that 'works' :) .. Is that a proposal for a 'final' syntax, or something to work with in the mean time? I said I've come to accept the Tuple *implementation*, but I'm absolutely not ready to accept the syntax baggage ;) I'd really rather see something that actually looks like a language feature in its final manifestation. Is natural and convenient to read and type. float t; ... (myStruct.pos, t, _, int err) = intersectThings(); Or something to this effect. That's about as clear and concise as it gets for my money.