Why tuples? [was: Why tuple Re: Why are unsigned to signed conversions implicit...?]

2011-04-11 Thread spir

On 04/11/2011 01:47 AM, Andrej Mitrovic wrote:

alias Tuple!(byte, "red", byte, "green", byte, "blue") RGBTuple;

RGBTuple GetRGB(COLORREF cref)
{
 RGBTuple rgb;
 rgb.red   = GetRValue(cref);
 rgb.green = GetGValue(cref);
 rgb.blue  = GetBValue(cref);

 return rgb;
}


[O your T]
Hello, andrej,

I'm trying to understand why people use tuples (outside multiple return values 
and variadic typetuples). Why do you prefere the above to:


struct RGBColor { byte red, green, blue; }

RGRColor GetRGB (COLORREF cref)
{
 RGBColor rgb;
 rgb.red   = GetRValue(cref);
 rgb.green = GetGValue(cref);
 rgb.blue  = GetBValue(cref);
 return rgb;
}

?
[/O your T]

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



Re: Why tuples? [was: Why tuple Re: Why are unsigned to signed conversions implicit...?]

2011-04-11 Thread Andrej Mitrovic
No reason. Sometimes I find a new feature in D and I like to try it
out in my code in various places, to see how it looks, how it works,
etc. In this case a simple struct would do. :)