Pre-SIP: A Syntax for Collection Literals

We could, but IMO [].toMap works just was well and does not require special syntax.

1 Like

Python also had the problem with zero element sets colliding with dicts, and they just decided {} is an empty dict snd you use set() for the empty set. In practice this isn’t a problem at all.

For Scala, that would mean using Map() for empty maps in the absence of target typing. Places with expected types we can just infer/instantiate the correct type of collection without boilerplate or ambiguity. I would expect the occassional case where an explicit collection constructor to be required won’t be a problem either

2 Likes

It’s not a problem per sĂ©, but it would be nice that, if we introduce a new ruleset, it does not come with exceptions at conception. See the trouble we have with the regularisation of the definition of the Tuple. It hurts orthogonality.

Further, and probably this has be said before, we have come this far without a syntax for collection literals. Do we really expect that introducing it would attract a whole new poule of users? I think not. Especially not, when it starts out with exceptions to the rule.

6 Likes