A Discussion of Tuple Syntax
Wyatt
wyatt.epp at gmail.com
Tue Aug 20 05:47:27 PDT 2013
On Tuesday, 20 August 2013 at 09:02:29 UTC, Mr. Anonymous wrote:
>
> Why not just leave an empty space, like php does:
>
> $info = array('coffee', 'brown', 'caffeine');
> // let's skip to only the third one
> list( , , $power) = $info;
> echo "I need $power!\n";
Bad idea. It's a visual thing-- quick! How wide is this tuple!?:
#(,front,,,,var,)
How long did it take you to be SURE that it's a seven-tuple? You
probably aren't even equipped to measure that so don't worry
about answering, but I'm guessing you start to appreciate why
it's a fairly inhumane solution (how drearily typical for PHP).
Ah, but what if it was supposed to be #(,front,,,,,var,)? Does
that change your result, now that you're taking the sixth element
rather than the seventh? All you did was forget a comma! By
contrast:
#(?,front,?,?,?,var,?,?) //at least gives us a better chance of
parsing it correctly.
My point here is we are human and we are fallible. The sooner we
acknowledge and internalise that, the better equipped we are to
make systems that don't suck for humans to use.
In that sense, I don't even really like this format because it's
still not especially resilient. Walter's talk about design that
eliminates patterns of human error resonated with me quite
strongly, you see. But in terms of language consistency it's not
much different from array literals, so I could accept it as a
compromise.
-Wyatt
More information about the Digitalmars-d
mailing list