Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 05, 2010 [phobos] Fwd: Tuple, TypeTuple, tupleof etc | ||||
---|---|---|---|---|
| ||||
It's about the messy situation around tuple nomenclature in Phobos: - TypeTuple can contain values too - Tuple is different from TypeTuple - tupleof is not a Tuple but a TypeTuple consisting of values Note also that "Tuple" has packed semantics and "TypeTuple" has expanded semantics. The two are really different in many aspects. What to do with them? Shin On July 6, bearophile posted to the newsgroup: > You have a "tupleof" struct attribute that gives a TypeTuple, and it can contain values too and not just types, and then you have a Tuple in Phobos that is something similar, but not exactly the same as, a TypeTuple. You can return a Tuple but not a TypeTuple. All this is messy, D newbies will have troubles. Having two slightly different kinds of tuples in a language is bad, but mixing their names in those ways is even worse. > > In my dlibs1 what's called Tuple is named Record and what's named TypeTuple is named Tuple, this is better because a record is quite similar to a struct (as named in Pascal-like languages too), while a Tuple is named tuple in the language too. The name "Record" is bad for this purpose because while it's structurally a struct, from an usage point of view it's more like a mathematical tuple. > > In the end I still think "Record" and "Tuple" are better names, despite their faults. Please think of the newbies :-) Can those two names in Phobos2 be changed? http://www.digitalmars.com/d/archives/digitalmars/D/Tuple_TypeTuple_tupleof_etc_113005.html |
October 13, 2010 [phobos] Fwd: Tuple, TypeTuple, tupleof etc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | Here's my thoughts.
Tuple should be kept as-is. But TypeTuple and tupleof should be renamed meta.Sequence and fieldsof, respectively. These names are better because they reflect facts more precisely. Let's see why I think so.
std.typecons' Tuple should be kept. A Tuple instance packs several run-time values in a single entity - it's really what called a tuple. So, the name should be kept as is.
On the other hand, TypeTuple should be renamed meta.Sequence due to
its peculiar nature... (a) It can contain anything but run-time values,
and (b) it automatically expands by itself. You can even use
TypeTuples for filling array literals and function arguments. They're
more like flat sequences of compile-time entities than packed tuples.
Also, the built-in tupleof property should be renamed. It's just a misnomer... It presents a run-time sequence of the all fields of an aggregate object, not a tuple of the aggregate. (what's that?) The name should be more intuitive and straightforward: fieldsof.
To sum up, I think we should take these actions:
1. Leave Tuple as is;
2. Deprecate TypeTuple with meta.Sequence; and
3. Deprecate tupleof with fieldsof.
The proposed nomenclature reflects the facts around the "three tuples" more precisely, and there's no confusion. What do you think?
P.S. Ah... maybe meta.Sequence can be replaced with the hot craze "tuple literals" if they can contain types and symbols. Sure, I'll be happy if so! (But they should be called sequence literals... ;-))
Shin
Shin Fujishiro <rsinfu at gmail.com> wrote:
> It's about the messy situation around tuple nomenclature in Phobos:
>
> - TypeTuple can contain values too
> - Tuple is different from TypeTuple
> - tupleof is not a Tuple but a TypeTuple consisting of values
>
> Note also that "Tuple" has packed semantics and "TypeTuple" has expanded semantics. The two are really different in many aspects. What to do with them?
>
>
> Shin
>
> On July 6, bearophile posted to the newsgroup:
>
> > You have a "tupleof" struct attribute that gives a TypeTuple, and it can contain values too and not just types, and then you have a Tuple in Phobos that is something similar, but not exactly the same as, a TypeTuple. You can return a Tuple but not a TypeTuple. All this is messy, D newbies will have troubles. Having two slightly different kinds of tuples in a language is bad, but mixing their names in those ways is even worse.
> >
> > In my dlibs1 what's called Tuple is named Record and what's named TypeTuple is named Tuple, this is better because a record is quite similar to a struct (as named in Pascal-like languages too), while a Tuple is named tuple in the language too. The name "Record" is bad for this purpose because while it's structurally a struct, from an usage point of view it's more like a mathematical tuple.
> >
> > In the end I still think "Record" and "Tuple" are better names, despite their faults. Please think of the newbies :-) Can those two names in Phobos2 be changed?
>
> http://www.digitalmars.com/d/archives/digitalmars/D/Tuple_TypeTuple_tupleof_etc_113005.html
|
October 12, 2010 [phobos] Fwd: Tuple, TypeTuple, tupleof etc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | On Tuesday, October 12, 2010 09:30:29 Shin Fujishiro wrote:
> Here's my thoughts.
>
> Tuple should be kept as-is. But TypeTuple and tupleof should be renamed meta.Sequence and fieldsof, respectively. These names are better because they reflect facts more precisely. Let's see why I think so.
>
> std.typecons' Tuple should be kept. A Tuple instance packs several run-time values in a single entity - it's really what called a tuple. So, the name should be kept as is.
>
> On the other hand, TypeTuple should be renamed meta.Sequence due to
> its peculiar nature... (a) It can contain anything but run-time values,
> and (b) it automatically expands by itself. You can even use
> TypeTuples for filling array literals and function arguments. They're
> more like flat sequences of compile-time entities than packed tuples.
>
> Also, the built-in tupleof property should be renamed. It's just a misnomer... It presents a run-time sequence of the all fields of an aggregate object, not a tuple of the aggregate. (what's that?) The name should be more intuitive and straightforward: fieldsof.
>
> To sum up, I think we should take these actions:
>
> 1. Leave Tuple as is;
> 2. Deprecate TypeTuple with meta.Sequence; and
> 3. Deprecate tupleof with fieldsof.
>
> The proposed nomenclature reflects the facts around the "three tuples" more precisely, and there's no confusion. What do you think?
>
>
> P.S. Ah... maybe meta.Sequence can be replaced with the hot craze "tuple literals" if they can contain types and symbols. Sure, I'll be happy if so! (But they should be called sequence literals... ;-))
I'm not sure if your exact names are the best (though they seem reasonably good), but I completely agree that renaming TypeTuple and tupleof to something other than tuple would be an excellent move. As they are, it's very easy to confuse them with Tuple, and it can cause a fair bit of headache to try and figure out what the differences are. And while they _are_ tuples of a sort, they're very limited in both representation and useage, so calling them tuples is at least somewhat misleading.
- Jonathan M Davis
|
October 13, 2010 [phobos] Fwd: Tuple, TypeTuple, tupleof etc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | vote++. This confusing situation about name 'tuple' should be improved. Kenji Hara |
January 03, 2011 [phobos] Fwd: Tuple, TypeTuple, tupleof etc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shin Fujishiro | I think the name "Tuple" is fine. You are right that "TypeTuple" is misleading. I suggest we call it "AliasTuple" because it essentially holds aliases.
Probably .tupleof will be difficult to change at this point.
Andrei
On 10/4/10 4:08 PM, Shin Fujishiro wrote:
> It's about the messy situation around tuple nomenclature in Phobos:
>
> - TypeTuple can contain values too
> - Tuple is different from TypeTuple
> - tupleof is not a Tuple but a TypeTuple consisting of values
>
> Note also that "Tuple" has packed semantics and "TypeTuple" has expanded semantics. The two are really different in many aspects. What to do with them?
>
>
> Shin
>
> On July 6, bearophile posted to the newsgroup:
>
>> You have a "tupleof" struct attribute that gives a TypeTuple, and it can contain values too and not just types, and then you have a Tuple in Phobos that is something similar, but not exactly the same as, a TypeTuple. You can return a Tuple but not a TypeTuple. All this is messy, D newbies will have troubles. Having two slightly different kinds of tuples in a language is bad, but mixing their names in those ways is even worse.
>>
>> In my dlibs1 what's called Tuple is named Record and what's named TypeTuple is named Tuple, this is better because a record is quite similar to a struct (as named in Pascal-like languages too), while a Tuple is named tuple in the language too. The name "Record" is bad for this purpose because while it's structurally a struct, from an usage point of view it's more like a mathematical tuple.
>>
>> In the end I still think "Record" and "Tuple" are better names, despite their faults. Please think of the newbies :-) Can those two names in Phobos2 be changed?
>
> http://www.digitalmars.com/d/archives/digitalmars/D/Tuple_TypeTuple_tupleof_etc_113005.html
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
Copyright © 1999-2021 by the D Language Foundation