On 04/09/2011 03:30 AM, Adam D. Ruppe wrote:
bearophile wrote:
>  With Color is becomes something like:
>  foreach (col; zip(reds, greens, blues))
>      image[x, y] = Color(col.tupleof);
That looks perfectly acceptable to me.

I might add an overload so opIndex can take a tuple too though,
so the zip example is a little easier, but I really prefer the
Color struct.

I prefere structs to tuples /everywhere/. They have 2 big advantages:
* builtin, well-known, literal notation,
* explicite: color.red versus color[0]

Actually, tuples look only useful to me for multiple return values, when they do not build a consistent unit, like (value, error). But I find this bad coding style (there is always a better solution, I guess).

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to