D with experimental features like tuple unpacking
Tobias Pankrath
tobias at pankrath.net
Fri Mar 22 07:23:52 PDT 2013
On Friday, 22 March 2013 at 13:41:31 UTC, renoX wrote:
>> The fact that you sort of can't easily index tuple of 3 ints
>> as a fixed array of 3 ints is a clear indication of a tendency
>> that I find disturbing.
>
> But there is a reason for this: tuple/structs can contain
> heterogeneous type whereas array contains only homogeneous
> type..
> So if you want to index a tuple/struct of say {int,int[128]}
> you have to build an array of pointers to these index, possible
> but clearly not free..
> So I wouldn't agree that tuple/struct are 'trivially
> substitutable' to array..
No. A tuple is by definition an ordered, finite sequence of
elements. There is no problem to index that.
tuple a = {
5;
true;
0.1
}
is(typeof(a[0]) == int)
is(typeof(a[1]) == bool)
More information about the Digitalmars-d
mailing list