October 08, 2010 Re: Tuple literal syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Wed, 06 Oct 2010 23:04:35 -0700, Walter Bright wrote: > There have been a couple of looong threads about tuples: > > http://www.digitalmars.com/d/archives/digitalmars/D/ Reddit_why_aren_t_people_using_D_93528.html > > http://www.digitalmars.com/d/archives/digitalmars/D/ Should_the_comma_operator_be_removed_in_D2_101321.html > > A lot of it foundered on what the syntax for tuple literals should be. The top of the list is simply enclosing them in ( ). The problem with this is > > (expression) > > Is that a parenthesized expression, or a tuple? This really matters, since (e)[0] means very different things for the two. Finally, I got to thinking, why not just make it a special case: > > > ( ) == tuple > (a) == parenthesized expression > (a,b) == tuple > (a,b,c) == tuple > (a,b,c,d) == tuple > > etc. > > No ambiguities! Only one special case. I submit this special case is rare, because who wants to define a function that returns a tuple of 1? Such will come about from generative programming, but: > > (a,b,c)[0] > > may be how the generative programming works, and that suggests: > > (a,0)[0] > > as how a user could generate a tuple of 1. Awkward, sure, but like I said, I think this would be rare. --vote; Personally, I don't think we should start adding a dedicated tuple syntax at this point. There are so many things that are more important, and besides, I think the library tuples are pretty cool. We should instead focus on making Tuple!(...) even better. -Lars |
October 08, 2010 Re: Tuple literal syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars T. Kyllingstad | Lars T. Kyllingstad:
> Personally, I don't think we should start adding a dedicated tuple syntax at this point. There are so many things that are more important, and besides, I think the library tuples are pretty cool. We should instead focus on making Tuple!(...) even better.
Tuples are a basic part of a language, they need to come before web tools, loggers, numeric libraries and so on. You build Phobos and all those things with a language. So if the language is better, you will work better.
From what I've seen so far in this thread the Tuple/Record library solution will be kept, but some built-in syntax sugar (unpacking, and maybe for the literals) helps in making tuple usage more handy and clean.
Bye,
bearophile
|
October 08, 2010 Re: Tuple literal syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Friday 08 October 2010 03:30:35 bearophile wrote:
> Lars T. Kyllingstad:
> > Personally, I don't think we should start adding a dedicated tuple syntax at this point. There are so many things that are more important, and besides, I think the library tuples are pretty cool. We should instead focus on making Tuple!(...) even better.
>
> Tuples are a basic part of a language, they need to come before web tools, loggers, numeric libraries and so on. You build Phobos and all those things with a language. So if the language is better, you will work better.
Agreed. But that doesn't mean that library solution isn't the best solution.
- Jonathan M Davis
|
October 08, 2010 Re: Tuple literal syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Fri, 08 Oct 2010 06:30:35 -0400, bearophile wrote:
> Lars T. Kyllingstad:
>
>> Personally, I don't think we should start adding a dedicated tuple syntax at this point. There are so many things that are more important, and besides, I think the library tuples are pretty cool. We should instead focus on making Tuple!(...) even better.
>
> Tuples are a basic part of a language, they need to come before web tools, loggers, numeric libraries and so on. [...]
I know, and I agree that *if* it is decided that tuples should be added to the language, it has to happen now. I just don't think it's necessary to do it at all.
-Lars
|
October 08, 2010 Re: Tuple literal syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 8/10/2010 9:30 PM, bearophile wrote: > Lars T. Kyllingstad: > >> Personally, I don't think we should start adding a dedicated tuple syntax >> at this point. There are so many things that are more important, and >> besides, I think the library tuples are pretty cool. We should instead >> focus on making Tuple!(...) even better. > > Tuples are a basic part of a language, they need to come before web tools, loggers, numeric libraries and so on. You build Phobos and all those things with a language. So if the language is better, you will work better. > > From what I've seen so far in this thread the Tuple/Record library solution will be kept, but some built-in syntax sugar (unpacking, and maybe for the literals) helps in making tuple usage more handy and clean. People responding on this thread still allude the basic question about exactly a tuple is supposed to be. This discussion is hitherto pointless. I think Andrei is in agreement .. here's the transcript from earlier on in this thread. Cheers Justin Johansson (prior transcript follows) On 10/7/10 7:23 CDT, Justin Johansson wrote: > On 7/10/2010 5:04 PM, Walter Bright wrote: >> There have been a couple of looong threads about tuples: >> >> http://www.digitalmars.com/d/archives/digitalmars/D/Reddit_why_aren_t_people_using_D_93528.html >> >> >> http://www.digitalmars.com/d/archives/digitalmars/D/Should_the_comma_operator_be_removed_in_D2_101321.html >> >> >> A lot of it foundered on what the syntax for tuple literals should be. >> The top of the list is simply enclosing them in ( ). The problem with >> this is > > Walter, please define exactly what a tuple is as being, both > in the context of your post and (presumably) in the D type system. > > Without a precise definition of exactly what a tuple is, > your post will at best elucidate responses that also lack a > precise understanding of a tuple is (supposed to be). > > There are already a number of responses to your post that focus > on syntax and without any semantic foundation. Wise words! It was exactly what I protested against. It discusses syntax without attacking any of the actual issues. Andrei |
Copyright © 1999-2021 by the D Language Foundation