Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 31, 2014 tuple (TypeTuple kind) multi-initialization. Actually documented? | ||||
---|---|---|---|---|
| ||||
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. |
March 31, 2014 Re: tuple (TypeTuple kind) multi-initialization. Actually documented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | 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 (Haskell, Rust, F#, Python, and more) that has tuples supports 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
|
March 31, 2014 Re: tuple (TypeTuple kind) multi-initialization. Actually documented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > No language that I know (Haskell, Rust, F#, Python, and more) 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 |
March 31, 2014 Re: tuple (TypeTuple kind) multi-initialization. Actually documented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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 (Haskell, Rust, F#, Python, and more) that has tuples supports 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.
|
Copyright © 1999-2021 by the D Language Foundation