On 20.02.2018 00:19, timotheecour wrote:
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
As promised [1], I have started setting up a DIP to improve tuple
ergonomics in D:
https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md
This DIP aims to make code like the following valid D:
...
Would this DIP allow array unpacking?
...
Yes, but would not be built-in.
eg, see this rust snippet from
https://gist.github.com/anonymous/9cfc3d1b057f7a137ccbfb94bf4bfcef
```
fn main() {
let (infile, colname, repl, outfile) =
std::env::args().skip(1).tuples().next().expect("Invalid args\n");
}
```
what would be the D equivalent under this DIP? (just for the array
unpacking part )
For a suitable implementation of "unpack":
void main(){
auto (infile, colname, repl, outfile) =
args[1..$].unpack!4("Invalid args\n");
}
Unfortunately, there is no good way to get rid of "4", as D does not
have backwards type inference.