Should we deprecate comma?
Marc Schütz" <schuetzm at gmx.net>
Marc Schütz" <schuetzm at gmx.net>
Mon Mar 24 05:48:00 PDT 2014
On Monday, 24 March 2014 at 12:10:40 UTC, Marc Schütz wrote:
> On Monday, 24 March 2014 at 01:28:02 UTC, Kenji Hara wrote:
>> I'm partially against to it.
>>
>> 1. I think removing comma operator does not have useful effect
>> for tuple
>> syntax discussion. For example:
>>
>> 1a. If you want to use parenthesis syntax (...) for tuple,
>> we should
>> resolve one-element tuple ambiguity first.
>> (exp) // one-element tuple, or just an expression ?
>> And, removing comma operator does not resolve this issue.
>
> I believe this is a non-issue. From a language-users POV, there
> should be no difference between a one-element tuple and an
> expression, thus there's no need to distinguish the two. (The
> actual implementation in the compiler may of course treat them
> differently.)
On second thought, this would probably lead to problems in
generic code, if we want to iterate over a tuple whose length we
do not know, and which happens to have one element only. So there
definitely needs to be a distinction between tuples and
non-tuples.
But as this is about syntax only, the question is: Do we even
need a dedicated syntax for one-element (and zero-element)
tuples? When those are needed, they can easily be created using
std.typecons.tuple(). The syntactic sugar is only really useful
when we have multiple values, be it for returning or for
assignment.
More information about the Digitalmars-d
mailing list