Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
March 16, 2011 Expression tuples | ||||
---|---|---|---|---|
| ||||
http://www.digitalmars.com/d/2.0/tuple.html // this example fails Tuple!(3, 7, 'c') typecons.d(298): Error: static assert "Attempted to instantiate Tuple with an invalid argument: 3" Even this fails: alias Tuple!(0) T; Is Tuple only meant to store types or named types? |
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | On Wed, 16 Mar 2011 21:07:08 +0100, simendsjo <simen.endsjo@pandavre.com> wrote: > http://www.digitalmars.com/d/2.0/tuple.html > > // this example fails > Tuple!(3, 7, 'c') > > typecons.d(298): Error: static assert "Attempted to instantiate Tuple > with an invalid argument: 3" > > Even this fails: > alias Tuple!(0) T; > > Is Tuple only meant to store types or named types? std.typecons.Tuple is a value type, mostly like those tuples you find in other languages like Python, Haskell, etc. What you are likely looking for is std.typetuple.Typetuple. -- Simen |
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | On Wed, 16 Mar 2011 16:28:48 -0400, Simen kjaeraas <simen.kjaras@gmail.com> wrote:
> On Wed, 16 Mar 2011 21:07:08 +0100, simendsjo <simen.endsjo@pandavre.com> wrote:
>
>> http://www.digitalmars.com/d/2.0/tuple.html
>>
>> // this example fails
>> Tuple!(3, 7, 'c')
>>
>> typecons.d(298): Error: static assert "Attempted to instantiate Tuple
>> with an invalid argument: 3"
>>
>> Even this fails:
>> alias Tuple!(0) T;
>>
>> Is Tuple only meant to store types or named types?
>
> std.typecons.Tuple is a value type, mostly like those tuples you find in
> other languages like Python, Haskell, etc.
> What you are likely looking for is std.typetuple.Typetuple.
>
If you read that page he is referring to, it seems like you should be able to create an expression tuple.
I don't know if that works with std.typecons.tuple.
In fact, I don't think I've ever seen some of the stuff that's in that page, especially the mixed type+expression tuple. Is it valid?
-Steve
|
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wed, 16 Mar 2011 21:51:37 +0100, Steven Schveighoffer <schveiguy@yahoo.com> wrote: > On Wed, 16 Mar 2011 16:28:48 -0400, Simen kjaeraas <simen.kjaras@gmail.com> wrote: > >> On Wed, 16 Mar 2011 21:07:08 +0100, simendsjo <simen.endsjo@pandavre.com> wrote: >> >>> http://www.digitalmars.com/d/2.0/tuple.html > If you read that page he is referring to, it seems like you should be able to create an expression tuple. > > I don't know if that works with std.typecons.tuple. > > In fact, I don't think I've ever seen some of the stuff that's in that page, especially the mixed type+expression tuple. Is it valid? Oh, absolutely. Given that you use the Tuple template declared at the top of the page. However, I would recommend the page be rewritten so as not to cause confusion between that and std.typecons.Tuple. -- Simen |
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | On Wed, 16 Mar 2011 17:31:06 -0400, Simen kjaeraas <simen.kjaras@gmail.com> wrote:
> On Wed, 16 Mar 2011 21:51:37 +0100, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
>
>> On Wed, 16 Mar 2011 16:28:48 -0400, Simen kjaeraas <simen.kjaras@gmail.com> wrote:
>>
>>> On Wed, 16 Mar 2011 21:07:08 +0100, simendsjo <simen.endsjo@pandavre.com> wrote:
>>>
>>>> http://www.digitalmars.com/d/2.0/tuple.html
>
>> If you read that page he is referring to, it seems like you should be able to create an expression tuple.
>>
>> I don't know if that works with std.typecons.tuple.
>>
>> In fact, I don't think I've ever seen some of the stuff that's in that page, especially the mixed type+expression tuple. Is it valid?
>
> Oh, absolutely. Given that you use the Tuple template declared at the top
> of the page. However, I would recommend the page be rewritten so as not
> to cause confusion between that and std.typecons.Tuple.
>
As I was confused there and thought we were talking about std.typecons.Tuple, I wholeheartedly agree :)
Now I am concerned, this looks like an oxymoron:
TypeTuple!(1, 2, 3)
Should we think about changing the name of std.typetuple.TypeTuple since it can clearly contain expressions as well as types? I would actually argue that TypeTuple should be called Tuple, and Tuple be called ValueTuple or something, but I understand we probably cannot do that at this point...
-Steve
|
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wednesday, March 16, 2011 14:43:20 Steven Schveighoffer wrote:
> On Wed, 16 Mar 2011 17:31:06 -0400, Simen kjaeraas
>
> <simen.kjaras@gmail.com> wrote:
> > On Wed, 16 Mar 2011 21:51:37 +0100, Steven Schveighoffer
> >
> > <schveiguy@yahoo.com> wrote:
> >> On Wed, 16 Mar 2011 16:28:48 -0400, Simen kjaeraas
> >>
> >> <simen.kjaras@gmail.com> wrote:
> >>> On Wed, 16 Mar 2011 21:07:08 +0100, simendsjo
> >>>
> >>> <simen.endsjo@pandavre.com> wrote:
> >>>> http://www.digitalmars.com/d/2.0/tuple.html
> >>
> >> If you read that page he is referring to, it seems like you should be able to create an expression tuple.
> >>
> >> I don't know if that works with std.typecons.tuple.
> >>
> >> In fact, I don't think I've ever seen some of the stuff that's in that page, especially the mixed type+expression tuple. Is it valid?
> >
> > Oh, absolutely. Given that you use the Tuple template declared at the top of the page. However, I would recommend the page be rewritten so as not to cause confusion between that and std.typecons.Tuple.
>
> As I was confused there and thought we were talking about std.typecons.Tuple, I wholeheartedly agree :)
>
> Now I am concerned, this looks like an oxymoron:
>
> TypeTuple!(1, 2, 3)
>
> Should we think about changing the name of std.typetuple.TypeTuple since it can clearly contain expressions as well as types? I would actually argue that TypeTuple should be called Tuple, and Tuple be called ValueTuple or something, but I understand we probably cannot do that at this point...
Regardless of whether TypeTuple can hold values or not, it really doesn't make sense to call it a tuple in the general sense, since it's always flat and cannot hold other tuples. IIRC, Andrei had a good suggestion for what to rename TypeTuple to, but unfortunately, I don't recall what it was at the moment. Regardless, I think that TypeTuple _should_ be renamed. It's far too easy to confuse it with Tuple. However, Tuple is definitely more of a tuple than TypeTuple is.
- Jonathan M Davis
|
March 16, 2011 Re: Expression tuples | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wed, 16 Mar 2011 22:43:20 +0100, Steven Schveighoffer <schveiguy@yahoo.com> wrote: > Now I am concerned, this looks like an oxymoron: > > TypeTuple!(1, 2, 3) > > Should we think about changing the name of std.typetuple.TypeTuple since it can clearly contain expressions as well as types? I would actually argue that TypeTuple should be called Tuple, and Tuple be called ValueTuple or something, but I understand we probably cannot do that at this point... Such has been discussed before. std.typecons.Tuple should also have a reasonably terse name, a virtue I feel ValueTuple does not fulfill. The problem is that those things contained in a std.typetuple.TypeTuple are so diverse, and thus hard to put in category. FreeTuple? TupleList? AnyTuple? AllTuple? Anyways, I'm off to sleep. Good... Well, I guess it's day to most of you on the other side of the pond. Good day, then. :p -- Simen |
Copyright © 1999-2021 by the D Language Foundation