Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Trailing commas for tuples #122

Open
letalvoj opened this issue May 29, 2020 · 1 comment
Open

Trailing commas for tuples #122

letalvoj opened this issue May 29, 2020 · 1 comment

Comments

@letalvoj
Copy link

letalvoj commented May 29, 2020

Trailing comma support is incomplete. Python allows statements such as

()  # reserved for `Unit` in scala
(1,)

The scala/scala3#9049 changes Tuple instantiation, to

Tuple()  // empty
Tuple(1) // size one
(2,3)

It would be nice if it was allowed to write

()    == Tuple()
(1, ) == Tuple(1)

instead. That would require to force () to be Unit with -scala2compat flag OR/AND migrate () to {} in cross-compiled codebases.

If that's not possible I'd vote for.

(, ) == Tuple()

CCing @nicolasstucki who is implementing the current changes.

@nicolasstucki
Copy link

The unit () syntax has been in Scala for too long to be able to remove it now without causing too much confusion. The trailing comma provides a good unambiguous shorthand.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants