Thoughts on possible tuple semantics

deadalnix deadalnix at gmail.com
Thu Aug 22 06:01:50 PDT 2013


On Thursday, 22 August 2013 at 12:50:06 UTC, Dicebot wrote:
> On Thursday, 22 August 2013 at 11:19:55 UTC, deadalnix wrote:
>> A sequence is an ordered set. You can have types, alias and 
>> values sequences. Values sequence can be runtime or compile 
>> time.
>
>> typeof(args) returns T, which is a type sequence (not a type !)
>> typeid(args) is invalid.
>
> 1) You propose typeof to result "not a type" entity. Well, if 
> it can be result of typeof, can be used to declare variables 
> and can be aliased - what makes it different from a type?
>

It is a sequence of types. It can be used to declare a sequence 
of variables.

> 2) is(typeof(tuple(42, 42)) == typeof(ctseq(42, 42))) == ? 
> (assuming typeof(args) == T and you don't make distinction 
> between runtime and compile-time value sequences.
>

In my proposal, tuple are a library construct. The proposal 
introduce the necessary tooling to implement them nicely.

is(typeof(42, 42) == (int, int));
is(typeof(tuple(42, 42)) == <a library defined struct>);

It could be defined as follow :

struct Tuple(T...) {
     T expand;
     alias expand this;
}

> Also you don't seem to cover mixed sequences which are 
> essential to D templates.

Theses are alias sequences.


More information about the Digitalmars-d mailing list