www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - tuple (TypeTuple kind) multi-initialization. Actually documented?

reply "monarch_dodra" <monarchdodra gmail.com> writes:
If you declare an instance of a tuple, eg TypeTuple!(int, int, 
int), you can initialize all members from a single argument. EG:

TypeTuple!(int, int, int) a = 5;

bearophile made a suggestion that we should deprecate this.
https://d.puremagic.com/issues/show_bug.cgi?id=6367

I'd like to know if this behavior even documented at all, or kind 
of "just happens to work".

In particular, it doesn't work in CTFE at all:
https://d.puremagic.com/issues/show_bug.cgi?id=12499

I'd like to ask the spec guru's to know which direction to take 
in dealing with both these issues.
Mar 31 2014
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
monarch_dodra:

 bearophile made a suggestion that we should deprecate this.
 https://d.puremagic.com/issues/show_bug.cgi?id=6367
It goes against the idea of tuple. No language that I know the initialization of a n-tuple with a scalar value. It's sloppy. And sloppy designs usually find a way to bite your rump later. Bye, bearophile
Mar 31 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:

 that has tuples supports the initialization of a n-tuple with a 
 scalar value.
In Python there is a way to build a n-tuple from a 1-tuple, but the seed is not a scalar, and this is an explicit syntax:
 (5,) * 3
(5, 5, 5) Bye, bearophile
Mar 31 2014
prev sibling parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Monday, 31 March 2014 at 21:05:11 UTC, bearophile wrote:
 monarch_dodra:

 bearophile made a suggestion that we should deprecate this.
 https://d.puremagic.com/issues/show_bug.cgi?id=6367
It goes against the idea of tuple. No language that I know the initialization of a n-tuple with a scalar value. It's sloppy. And sloppy designs usually find a way to bite your rump later.
Yes, but at this point, I (we?) don't even know if it's intended behavior to begin with. If it was an accident it worked to begin with, then it's fate should be sealed pretty fast. The fact that CTFE doesn't seem to work with it seems (to me) an indication of that.
Mar 31 2014