# Language Design

**URL:** https://contributors.scala-lang.org/c/language-design/9.md?page=3

[Latest](https://contributors.scala-lang.org/latest.md) · [Categories](https://contributors.scala-lang.org/categories.md)

**Page:** 4

---

## [Scala 3, macro annotations and code generation](https://contributors.scala-lang.org/t/scala-3-macro-annotations-and-code-generation/6035)

<div class="topic-metadata">

**Author:** [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Replies:** 70\
**Last updated:** [April 15, 2025, 1:48am UTC](https://contributors.scala-lang.org/t/scala-3-macro-annotations-and-code-generation/6035 "2025-04-15T01:48:04Z")

</div>

Scala 3, macro annotations and code generation Hi all, Back in 2018, Macros: the Plan for Scala 3 | The Scala Programming Language described how we expected macros, and in particular macro annotations, to eventually loo…

---

## [Generic string literals](https://contributors.scala-lang.org/t/generic-string-literals/7091)

<div class="topic-metadata">

**Author:** [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Replies:** 4\
**Last updated:** [April 7, 2025, 9:11pm UTC](https://contributors.scala-lang.org/t/generic-string-literals/7091 "2025-04-07T21:11:58Z")

</div>

Hey there, now that we have generic number literals, is there any reason why we can’t have generic string literals too? This would for example be useful for URLs. Currently the best we can do is a string interpolator, w…

---

## [The status of \`with\` in Scala 3](https://contributors.scala-lang.org/t/the-status-of-with-in-scala-3/4531)

<div class="topic-metadata">

**Author:** [@bmeesters](https://contributors.scala-lang.org/u/bmeesters)\
**Replies:** 21\
**Last updated:** [April 6, 2025, 11:04am UTC](https://contributors.scala-lang.org/t/the-status-of-with-in-scala-3/4531 "2025-04-06T11:04:38Z")

</div>

A while ago the proposal was made replace inheriting multiple traits using with with using , . Partly because that is what other languages do. But mostly because with was considered as a keyword for the new implicit syst…

---

## [The "name in type" problem](https://contributors.scala-lang.org/t/the-name-in-type-problem/7082)

<div class="topic-metadata">

**Author:** [@Sporarum](https://contributors.scala-lang.org/u/Sporarum)\
**Replies:** 6\
**Last updated:** [March 27, 2025, 4:32pm UTC](https://contributors.scala-lang.org/t/the-name-in-type-problem/7082 "2025-03-27T16:32:28Z")

</div>

Introduction I recently learned of a feature/bug: def foo(f: (x: Int) ?=\> Int) = f(using 0) foo(x.toString) // returns "0" This seems like a neat feature, we don’t need to make these kinds of things anymore: def ctx(…

---

## [Named tuples are not considered to be disjoint from any type](https://contributors.scala-lang.org/t/named-tuples-are-not-considered-to-be-disjoint-from-any-type/7070)

<div class="topic-metadata">

**Author:** [@soronpo](https://contributors.scala-lang.org/u/soronpo)\
**Replies:** 9\
**Last updated:** [March 18, 2025, 7:43pm UTC](https://contributors.scala-lang.org/t/named-tuples-are-not-considered-to-be-disjoint-from-any-type/7070 "2025-03-18T19:43:54Z")

</div>

Due to the implementation of NamedTuple as opaque type with an upper-bound of Any, they are not considered to be disjoint from any type. This significantly limits their usage in match types: scastie sealed trait Foo t…

---

## [Should a \`def\` with a singleton type be considered stable?](https://contributors.scala-lang.org/t/should-a-def-with-a-singleton-type-be-considered-stable/7075)

<div class="topic-metadata">

**Author:** [@Sporarum](https://contributors.scala-lang.org/u/Sporarum)\
**Replies:** 8\
**Last updated:** [March 18, 2025, 12:47pm UTC](https://contributors.scala-lang.org/t/should-a-def-with-a-singleton-type-be-considered-stable/7075 "2025-03-18T12:47:34Z")

</div>

vals make stable identifiers: class Graph { class Node { val graph = Graph.this // val (without singleton type) } def useNode(node: Node) = ??? } def useNode(node: Graph#Node) = node.graph.useNode(node) // \[.…

---

## [Make genericNumberLiterals non experimental?](https://contributors.scala-lang.org/t/make-genericnumberliterals-non-experimental/7063)

<div class="topic-metadata">

**Author:** [@charpov](https://contributors.scala-lang.org/u/charpov)\
**Replies:** 10\
**Last updated:** [March 12, 2025, 2:46pm UTC](https://contributors.scala-lang.org/t/make-genericnumberliterals-non-experimental/7063 "2025-03-12T14:46:19Z")

</div>

Is there a plan to make genericNumberLiterals non experimental? 3.7.0? I’ve been using it in several projects and found it quite convenient, except for that hassle of being experimental.

---

## [Cross-File Sealing for Sealed Traits with Explicit Subtype Declaration](https://contributors.scala-lang.org/t/cross-file-sealing-for-sealed-traits-with-explicit-subtype-declaration/7055)

<div class="topic-metadata">

**Author:** [@arie-benichou](https://contributors.scala-lang.org/u/arie-benichou)\
**Replies:** 2\
**Last updated:** [February 23, 2025, 10:48pm UTC](https://contributors.scala-lang.org/t/cross-file-sealing-for-sealed-traits-with-explicit-subtype-declaration/7055 "2025-02-23T22:48:40Z")

</div>

As kindly advised by @soronpo, i am posting here a new thread related to Enabling sealed traits across different files with union type desugaring - #5 by morgen-peschke As discussed with @som-snytt in Multi-file ADTs · …

---

## [Why does Scala 3 macros require you to construct AST's manually?](https://contributors.scala-lang.org/t/why-does-scala-3-macros-require-you-to-construct-asts-manually/7040)

<div class="topic-metadata">

**Author:** [@arturaz](https://contributors.scala-lang.org/u/arturaz)\
**Replies:** 3\
**Last updated:** [February 12, 2025, 1:16pm UTC](https://contributors.scala-lang.org/t/why-does-scala-3-macros-require-you-to-construct-asts-manually/7040 "2025-02-12T13:16:40Z")

</div>

Hi there. I previously implemented macros within Roslyn (the C# compiler) and there you could do SyntaxFactory.ParseExpression("your C# code here") (docs) to get the AST, which is a lot more convenient than generating t…

---

## [General type projections through match types](https://contributors.scala-lang.org/t/general-type-projections-through-match-types/7031)

<div class="topic-metadata">

**Author:** [@Krever](https://contributors.scala-lang.org/u/Krever)\
**Replies:** 9\
**Last updated:** [February 7, 2025, 3:24pm UTC](https://contributors.scala-lang.org/t/general-type-projections-through-match-types/7031 "2025-02-07T15:24:27Z")

</div>

In the recent discussion about scala 3 migration, the topic of dropped general type projections was brought up. I understand the general reason for unsoundness, but we have a working and generic enough alternative throu…

---

## [Status of Tupled Function](https://contributors.scala-lang.org/t/status-of-tupled-function/6972)

<div class="topic-metadata">

**Author:** [@bulbyvr](https://contributors.scala-lang.org/u/bulbyvr)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 4:37pm UTC](https://contributors.scala-lang.org/t/status-of-tupled-function/6972 "2025-01-25T16:37:13Z")

</div>

What is the status of Tupled Function? I don’t see any threads about TupledFunction.

---

## [Code generation](https://contributors.scala-lang.org/t/code-generation/6807)

<div class="topic-metadata">

**Author:** [@rcano](https://contributors.scala-lang.org/u/rcano)\
**Replies:** 11\
**Last updated:** [January 19, 2025, 12:11pm UTC](https://contributors.scala-lang.org/t/code-generation/6807 "2025-01-19T12:11:24Z")

</div>

On the topic of macro annotations and AST generation, it’s been often mentioned that this is undesirable and that a better approach would be code generation. In scala 2 we do have ast manipulation¹ but in scala 3 we don’…

---

## [Support \`@switch\` for type-based pattern matches](https://contributors.scala-lang.org/t/support-switch-for-type-based-pattern-matches/5470)

<div class="topic-metadata">

**Author:** [@harpocrates](https://contributors.scala-lang.org/u/harpocrates)\
**Replies:** 8\
**Last updated:** [January 13, 2025, 8:49am UTC](https://contributors.scala-lang.org/t/support-switch-for-type-based-pattern-matches/5470 "2025-01-13T08:49:27Z")

</div>

Java 17 came with a preview of JEP 406. This makes it possible to pattern match based on the type of the scrutinee expression. Looking at the javap -c output of these new type-based switches, I see that they work using a…

---

## [Alphanumeric infix warning - behavior with -source future](https://contributors.scala-lang.org/t/alphanumeric-infix-warning-behavior-with-source-future/6987)

<div class="topic-metadata">

**Author:** [@OndrejSpanel](https://contributors.scala-lang.org/u/OndrejSpanel)\
**Replies:** 5\
**Last updated:** [January 10, 2025, 11:32am UTC](https://contributors.scala-lang.org/t/alphanumeric-infix-warning-behavior-with-source-future/6987 "2025-01-10T11:32:30Z")

</div>

I wrote in: @infix to unlock operator notation is, in fact, controversial! - #19 by OndrejSpanel (deleted by accident now, when trying to quote it, unable to restore): At the moment I use following string in my scalacO…

---

## [Inline convertion in pattern matching's \`if\` guard](https://contributors.scala-lang.org/t/inline-convertion-in-pattern-matchings-if-guard/6962)

<div class="topic-metadata">

**Author:** [@hepin1989](https://contributors.scala-lang.org/u/hepin1989)\
**Replies:** 14\
**Last updated:** [January 5, 2025, 4:18am UTC](https://contributors.scala-lang.org/t/inline-convertion-in-pattern-matchings-if-guard/6962 "2025-01-05T04:18:40Z")

</div>

Encounter this problem when using fastparse to parse jsonpath RFC. private def \`int\`\[\_: P\]: P\[Int\] = P("0" | ("-".? ~ \`DIGIT1\` ~ \`DIGIT\`.rep)).! .map(\_.toLong) .collect { case value if MIN\_INTEGER \< valu…

---

## [Remove local tuple allocation](https://contributors.scala-lang.org/t/remove-local-tuple-allocation/6969)

<div class="topic-metadata">

**Author:** [@hepin1989](https://contributors.scala-lang.org/u/hepin1989)\
**Replies:** 12\
**Last updated:** [December 30, 2024, 3:06pm UTC](https://contributors.scala-lang.org/t/remove-local-tuple-allocation/6969 "2024-12-30T15:06:34Z")

</div>

When I looked at the code of https://benjdd.com/languages3/ Scala-Native is fast, but Scala on the JVM is slow !\[image|608x500\](upload://owtLxsxOjjVHIvmufH9fw6tWyYn.jpeg where languages/levenshtein/scala/code.scal…

---

## [Could Someone Give me Advice on Best Practices for Typeclass Derivation in Scala 3?](https://contributors.scala-lang.org/t/could-someone-give-me-advice-on-best-practices-for-typeclass-derivation-in-scala-3/6966)

<div class="topic-metadata">

**Author:** [@lizaclarraa](https://contributors.scala-lang.org/u/lizaclarraa)\
**Replies:** 2\
**Last updated:** [December 17, 2024, 3:48pm UTC](https://contributors.scala-lang.org/t/could-someone-give-me-advice-on-best-practices-for-typeclass-derivation-in-scala-3/6966 "2024-12-17T15:48:23Z")

</div>

Hello there, I have been diving deeper into Scala 3 and exploring its new features, particularly typeclass derivation. While I understand the basic concept of derives and how it simplifies boilerplate for common use cas…

---

## [Named tuples: Bag-like operations](https://contributors.scala-lang.org/t/named-tuples-bag-like-operations/6956)

<div class="topic-metadata">

**Author:** [@aboisvert](https://contributors.scala-lang.org/u/aboisvert)\
**Replies:** 12\
**Last updated:** [December 16, 2024, 8:11pm UTC](https://contributors.scala-lang.org/t/named-tuples-bag-like-operations/6956 "2024-12-16T20:11:12Z")

</div>

As an early adopter of named tuples, there are situations where I’d like to treat named tuples as a bag of named values rather than a strict sequence of named values. For example, I’d love to be able to assign tuples th…

---

## [Whitespace syntax for parameter lists](https://contributors.scala-lang.org/t/whitespace-syntax-for-parameter-lists/6854)

<div class="topic-metadata">

**Author:** [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Replies:** 5\
**Last updated:** [December 9, 2024, 2:50am UTC](https://contributors.scala-lang.org/t/whitespace-syntax-for-parameter-lists/6854 "2024-12-09T02:50:36Z")

</div>

Hey there, Since the introduction of the “fewer braces” syntax (which I’m a fan of), there is an odd inconsistency in the language: unary functions can be called with whitespace syntax, but parens and commas are require…

---

## [Derived Ordering for simple enum?](https://contributors.scala-lang.org/t/derived-ordering-for-simple-enum/5243)

<div class="topic-metadata">

**Author:** [@philipschwarz](https://contributors.scala-lang.org/u/philipschwarz)\
**Replies:** 18\
**Last updated:** [December 8, 2024, 6:24pm UTC](https://contributors.scala-lang.org/t/derived-ordering-for-simple-enum/5243 "2024-12-08T18:24:04Z")

</div>

Hi all :raised\_hand\_with\_fingers\_splayed: When I read the beginning of Type Class Derivation | Scala 3 Language Reference | Scala Documentation, I think to myself that I might be able to do the Scala equivalent of Haske…

---

## [Struggling to express dependent givens under modularity](https://contributors.scala-lang.org/t/struggling-to-express-dependent-givens-under-modularity/6942)

<div class="topic-metadata">

**Author:** [@alvae](https://contributors.scala-lang.org/u/alvae)\
**Replies:** 0\
**Last updated:** [November 28, 2024, 4:32pm UTC](https://contributors.scala-lang.org/t/struggling-to-express-dependent-givens-under-modularity/6942 "2024-11-28T16:32:47Z")

</div>

I’am struggling to express the following idea: You have a type class representing collections You define a type representing slices of a collection You state that slices are collections having the same associated types…

---

## [Allow renames of givens generated by 'derives' clauses](https://contributors.scala-lang.org/t/allow-renames-of-givens-generated-by-derives-clauses/6856)

<div class="topic-metadata">

**Author:** [@arainko](https://contributors.scala-lang.org/u/arainko)\
**Replies:** 6\
**Last updated:** [November 27, 2024, 5:57pm UTC](https://contributors.scala-lang.org/t/allow-renames-of-givens-generated-by-derives-clauses/6856 "2024-11-27T17:57:01Z")

</div>

Currently whenever we use a derives clause to generate a typeclass instance its name in the companion object is generated as ‘derived$NameOfTheTypeclassType’ eg. for a typeclass like Show it’d be derived$Show. I propose…

---

## [Higher-kinded type lambda placeholders remain a "rough edge" of the new given syntax](https://contributors.scala-lang.org/t/higher-kinded-type-lambda-placeholders-remain-a-rough-edge-of-the-new-given-syntax/6810)

<div class="topic-metadata">

**Author:** [@benhutchison](https://contributors.scala-lang.org/u/benhutchison)\
**Replies:** 2\
**Last updated:** [November 25, 2024, 12:16pm UTC](https://contributors.scala-lang.org/t/higher-kinded-type-lambda-placeholders-remain-a-rough-edge-of-the-new-given-syntax/6810 "2024-11-25T12:16:49Z")

</div>

I have been experimenting with the new given syntaxes in Scala 3.6.1. Fairly successfully, in that with some effort it’s been possible to migrate an existing codebase onto the new syntax without hitting any showstopper i…

---

## [Making io.StdIn.readLine imported by default](https://contributors.scala-lang.org/t/making-io-stdin-readline-imported-by-default/6803)

<div class="topic-metadata">

**Author:** [@windymelt](https://contributors.scala-lang.org/u/windymelt)\
**Replies:** 24\
**Last updated:** [November 18, 2024, 4:08pm UTC](https://contributors.scala-lang.org/t/making-io-stdin-readline-imported-by-default/6803 "2024-11-18T16:08:03Z")

</div>

As we know, we can use print and println without any imports. Thanks to this, we can teach beginners how to print something. However, reading something is tough in current package hierarchy (We should call io.StdIn.read…

---

## [Joining the dots on recent Implicit Prioritization changes and some Scala history](https://contributors.scala-lang.org/t/joining-the-dots-on-recent-implicit-prioritization-changes-and-some-scala-history/6814)

<div class="topic-metadata">

**Author:** [@benhutchison](https://contributors.scala-lang.org/u/benhutchison)\
**Replies:** 3\
**Last updated:** [November 13, 2024, 9:56am UTC](https://contributors.scala-lang.org/t/joining-the-dots-on-recent-implicit-prioritization-changes-and-some-scala-history/6814 "2024-11-13T09:56:05Z")

</div>

For those of us using typeclass-based (TC) abstraction hierarchies, including Cats & Typelevel libraries, I’m not sure the full impact of the recent change to implicit resolution has been fully appreciated, nor its link …

---

## [Enum candy: the last mile](https://contributors.scala-lang.org/t/enum-candy-the-last-mile/6760)

<div class="topic-metadata">

**Author:** [@regiskuckaertz](https://contributors.scala-lang.org/u/regiskuckaertz)\
**Replies:** 15\
**Last updated:** [November 7, 2024, 2:44pm UTC](https://contributors.scala-lang.org/t/enum-candy-the-last-mile/6760 "2024-11-07T14:44:42Z")

</div>

When access to term members inside an ADT is exclusively done via pattern matching or combinators, having to name members is tedious and useless. For instance: enum Tree\[+T\]: case B(left: Tree\[T\], value: T, right: Tre…

---

## [Pattern match only in for comprehension](https://contributors.scala-lang.org/t/pattern-match-only-in-for-comprehension/6809)

<div class="topic-metadata">

**Author:** [@OndrejSpanel](https://contributors.scala-lang.org/u/OndrejSpanel)\
**Replies:** 0\
**Last updated:** [November 7, 2024, 2:05pm UTC](https://contributors.scala-lang.org/t/pattern-match-only-in-for-comprehension/6809 "2024-11-07T14:05:51Z")

</div>

Would it be possible to extend for comprehension so that it accepts pattern match in alias declaration, like this? val sourceId = for { source \<- action.actionSource case id: AsEntity = sourc…

---

## [Testing presence of type in union](https://contributors.scala-lang.org/t/testing-presence-of-type-in-union/6800)

<div class="topic-metadata">

**Author:** [@Katrix](https://contributors.scala-lang.org/u/Katrix)\
**Replies:** 3\
**Last updated:** [October 29, 2024, 9:49am UTC](https://contributors.scala-lang.org/t/testing-presence-of-type-in-union/6800 "2024-10-29T09:49:52Z")

</div>

Recently, I thought about how I encode nullness in my database library, and if I should change it. Currently I use Option to encode null, and ensure Option is never nested by using this type. sealed trait NullableHelper…

---

## [Why is the values method on enum an Array? Could it be an immutable ArraySeq?](https://contributors.scala-lang.org/t/why-is-the-values-method-on-enum-an-array-could-it-be-an-immutable-arrayseq/6789)

<div class="topic-metadata">

**Author:** [@bjornregnell](https://contributors.scala-lang.org/u/bjornregnell)\
**Replies:** 26\
**Last updated:** [October 26, 2024, 1:56pm UTC](https://contributors.scala-lang.org/t/why-is-the-values-method-on-enum-an-array-could-it-be-an-immutable-arrayseq/6789 "2024-10-26T13:56:07Z")

</div>

Why does the values method in the companion of every enum give an Array and not an immutable ArraySeq? Welcome to Scala 3.5.1 (21.0.4, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. s…

---

## [Ability to force the caller to specify a type parameter for a polymorphic method](https://contributors.scala-lang.org/t/ability-to-force-the-caller-to-specify-a-type-parameter-for-a-polymorphic-method/2116)

<div class="topic-metadata">

**Author:** [@AMatveev](https://contributors.scala-lang.org/u/AMatveev)\
**Replies:** 29\
**Last updated:** [October 23, 2024, 6:30am UTC](https://contributors.scala-lang.org/t/ability-to-force-the-caller-to-specify-a-type-parameter-for-a-polymorphic-method/2116 "2024-10-23T06:30:47Z")

</div>

We need black box macros for final class definition. For example create\[Card\] which will generate something like new Card { def this2Tag\[MAVI \<: AnyRef\](avi: MAVI)(implicit tag: TypeTag\[MAVI\]): TypeTag\[MAVI\]…

[Previous page](https://contributors.scala-lang.org/c/language-design/9.md?page=2)

[Next page](https://contributors.scala-lang.org/c/language-design/9.md?page=4)
