On Monday, 24 March 2014 at 12:39:53 UTC, Marc Schütz wrote:
On Monday, 24 March 2014 at 12:25:58 UTC, w0rp wrote:
Please kill the comma operator with fire. Is is just bad.
On Monday, 24 March 2014 at 12:20:11 UTC, Marc Schütz wrote:
Or, if you really want to distinguish them, this would work:
(1,2) two-element tuple
(1,) one-element tuple
(1) simple expression
(,) empty tuple
I am a regular Python user, and I advise against using this
syntax for tuples. I have been bitten many times by something
which I thought was a tuple becoming an expression and
something I thought was a simple expression becoming a tuple.
It may be less of an issue in a static language, but it will
still be an issue. I don't have an alternative syntax to
propose.
I'm not familiar with Python. What is the difference between a
one-element tuple and an expression? Are Python tuples just
arrays?
Consider the following.
(1, 2)
(1, 2)
(1)
1
(1 * (3 * 4,))
(-1, )
(1 * (3 - 4,) * 2)
(-1, -1)
foo = lambda : 3
(
... foo()
... )
3
(
... foo(),
... )
(3, )
I see this kind of confusion happen often, and the convenient
syntax becomes a burden.