improvement-proposals icon indicating copy to clipboard operation
improvement-proposals copied to clipboard

SIP-58 - Named Tuples

Open odersky opened this issue 1 year ago • 6 comments
trafficstars

This is the promised SIP for named tuples

odersky avatar Jan 13 '24 18:01 odersky

There are a lot of good suggestions to add more sections to the proposal, but I am out of time to do this. Maybe someone else wants to help? There's an implementation to play with to experiment and find out more.

odersky avatar Jan 14 '24 09:01 odersky

would name tuples be incubated as experimenta feature for a period of time? guess there could be more feedback after people start to play with them

would really like to see how they play with type level programming

3xau1o avatar Jan 28 '24 23:01 3xau1o

would name tuples be incubated as experimenta feature for a period of time?

Every new Scala feature is first approved for experimentation, before it is approved to be shipped. The time between those milestones is at least a month, and should be longer for controversial features or features that interact with significant parts of the language. What is approved as experimental is only testable under a nightly or snapshot versions of the compiler and usually involves enabling some flag or importing language.experimental.

soronpo avatar Jan 29 '24 01:01 soronpo

@kyouko-taiga I changed the stage label to stage:implementation - as that is required by our state transition diagram (and the script that generates the sips website):

bishabosha avatar May 31 '24 09:05 bishabosha

A few points raised at the last SIP meeting:

  • There is currently a soundness bug with NamedTuple.From: https://github.com/scala/scala3/issues/20517
    • we believe the fix will require refining the specification of NamedTuple.From to reuse a check for reduction from the match type logic: https://github.com/scala/scala3/blob/0a3497bf7f0ac032f98d36cf1713e8926b5d176c/compiler/src/dotty/tools/dotc/core/TypeComparer.scala#L3397-L3410. This should be reflected in the spec, which should link to the corresponding section of https://docs.scala-lang.org/sips/match-types-spec.html (but it seems to me that right now the match type spec does not precisely defined "concrete" either? Note also that the current match type concreteness check implementation is too lax in some cases: https://github.com/scala/scala3/issues/20518)
  • @sjrd suggested that NamedTuple should be implemented as a class (with a custom erasure) rather than an abstract type to avoid unintuitive restrictions related to match types (e.g., https://github.com/scala/scala3/issues/20453)
    • I've also recently realized that pattern matching on a quoted type is broken for parameterized abstract types (you get a MatchError: https://github.com/scala/scala3/issues/16782), this means that meta-programming with NamedTuple is significantly harder than with regular Tuple currently.

smarter avatar Jun 24 '24 16:06 smarter

Disallow some opaque type aliases in match type patterns #20913 should address the problem with failing match type reductions. It serves as a safety net ensuring that match type reduction on opaque aliases will not fail later.

odersky avatar Jul 01 '24 17:07 odersky

I changed the stage label to stage:implementation - as that is required by our state transition diagram (and the script that generates the sips website)

Does that mean that the design has been accepted by the SIP Committee? If that’s the case, it would be good to merge the PR so that the proposal gets its own page like e.g. https://docs.scala-lang.org/sips/polymorphic-eta-expansion.html.

julienrf avatar Aug 15 '24 12:08 julienrf

I changed the stage label to stage:implementation - as that is required by our state transition diagram (and the script that generates the sips website)

Does that mean that the design has been accepted by the SIP Committee? If that’s the case, it would be good to merge the PR so that the proposal gets its own page like e.g. https://docs.scala-lang.org/sips/polymorphic-eta-expansion.html.

Only as experimental. Not final yet.

soronpo avatar Aug 15 '24 12:08 soronpo

@lihaoyi can we vote to accept this tomorrow?

soronpo avatar Sep 26 '24 10:09 soronpo

Sure let's vote

lihaoyi avatar Sep 26 '24 10:09 lihaoyi

It would be good if the recommendations of each assignee could be stated here prior to the vote.

bjornregnell avatar Sep 26 '24 14:09 bjornregnell

I agree. Could the assignees update the agenda?

kyouko-taiga avatar Sep 26 '24 14:09 kyouko-taiga

I recommend YES to accept.

soronpo avatar Sep 26 '24 15:09 soronpo

I recommend accepting this proposal

smarter avatar Sep 26 '24 16:09 smarter