Bug 7624 – std.typecons.Tuple slicing

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-01T15:37:08Z
Last change time
2024-12-13T17:58:52Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18422 →

Comments

Comment #0 by bearophile_hugs — 2012-03-01T15:37:08Z
std.typecons.Tuple supports both a "slice" method and normal array slicing syntax: import std.stdio, std.typecons; void main() { Tuple!(int,float,string,ubyte) t4; t4[2] = "XXX"; t4[3] = 99; writeln(t4); writeln(typeid(typeof(t4)), "\n"); auto t2a = t4.slice!(1, 3); writeln(t2a); writeln(typeid(typeof(t2a)), "\n"); auto t2b = t4[1 .. 3]; writeln(t2b); writeln(typeid(typeof(t2b)), "\n"); } Outout with DMD 2.059head: Tuple!(int,float,string,ubyte)(0, nan, "XXX", 99) std.typecons.Tuple!(int,float,string,ubyte).Tuple Tuple!(float,string)(nan, "XXX") std.typecons.Tuple!(float,string).Tuple nanXXX (float,immutable(char)[]) But the natural syntax, using [1..3], returns a typetuple. Having two different kinds of tuples in a language is confusing, but slicing a kind tuple and see as a result the other kind of tuple is a bit too much confusing. Is it possible to modify D/Phobos to make t4[1..3] return a std.typecons.Tuple (and then deprecate the "slice" method)?
Comment #1 by robert.schadek — 2024-12-13T17:58:52Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18422 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB