-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
141 lines (141 loc) · 36.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html><html data-githubContributorsUrl="https://api.github.com/repos/scala/scala3" data-githubContributorsFilename="docs/_docs/reference/overview.md" data-pathToRoot="" data-rawLocation="index" data-dynamicSideMenu="false"><head><meta charset="utf-8"></meta><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"></meta><title>Scala 3 Reference</title><link rel="shortcut icon" type="image/x-icon" href="favicon.ico"></link><script type="text/javascript" src="scripts/theme.js"></script><script type="text/javascript" src="scripts/searchData.js" defer="true"></script><script type="text/javascript" src="scripts/scastieConfiguration.js" defer="true"></script><link rel="stylesheet" href="styles/theme/bundle.css"></link><link rel="stylesheet" href="styles/theme/components/bundle.css"></link><link rel="stylesheet" href="styles/theme/components/button/bundle.css"></link><link rel="stylesheet" href="styles/theme/layout/bundle.css"></link><link rel="stylesheet" href="styles/nord-light.css"></link><link rel="stylesheet" href="styles/dotty-icons.css"></link><link rel="stylesheet" href="styles/filter-bar.css"></link><link rel="stylesheet" href="styles/code-snippets.css"></link><link rel="stylesheet" href="styles/searchbar.css"></link><link rel="stylesheet" href="styles/social-links.css"></link><link rel="stylesheet" href="styles/versions-dropdown.css"></link><link rel="stylesheet" href="styles/content-contributors.css"></link><link rel="stylesheet" href="styles/fontawesome.css"></link><script type="text/javascript" src="hljs/highlight.pack.js" defer="true"></script><script type="text/javascript" src="scripts/hljs-scala3.js" defer="true"></script><script type="text/javascript" src="scripts/ux.js" defer="true"></script><script type="text/javascript" src="scripts/common/component.js" defer="true"></script><script type="text/javascript" src="scripts/common/utils.js" defer="true"></script><script type="text/javascript" src="scripts/components/FilterBar.js" defer="true"></script><script type="text/javascript" src="scripts/components/DocumentableList.js" defer="true"></script><script type="text/javascript" src="scripts/components/Input.js" defer="true"></script><script type="text/javascript" src="scripts/components/FilterGroup.js" defer="true"></script><script type="text/javascript" src="scripts/components/Filter.js" defer="true"></script><script type="text/javascript" src="scripts/scaladoc-scalajs.js" defer="true"></script><script type="text/javascript" src="scripts/contributors.js" defer="true"></script><script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js" defer="true"></script><script type="text/javascript" src="https://d3js.org/d3.v6.min.js" defer="true"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/graphlib-dot@0.6.2/dist/graphlib-dot.min.js" defer="true"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dagre-d3/0.6.1/dagre-d3.min.js" defer="true"></script><script type="text/javascript" src="https://scastie.scala-lang.org/embedded.js" defer="true"></script><script type="text/javascript" src="scripts/data.js" defer="true"></script><link rel="stylesheet" href="styles/staticsitestyles.css"></link><script>var pathToRoot = "";</script><link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="/css/dottydoc.css"></head><body><div id=""><div id="header" class="body-small"><div class="header-container-left"><a href="" class="logo-container"><span id="project-logo" class="project-logo"><img src="project-logo/logo.svg"></img></span><span id="dark-project-logo" class="project-logo"><img src="project-logo/logo_dark.svg"></img></span><span class="project-name h300">Scala 3 Reference</span></a><span onclick="dropdownHandler(event)" class="text-button with-arrow" id="dropdown-trigger"><a><div class="projectVersion">3.5.0</div></a></span><div id="version-dropdown" class="dropdown-menu"></div></div><div class="header-container-right"><button id="search-toggle" class="icon-button"></button><a href="https://docs.scala-lang.org/" class="text-button">Learn</a><a href="https://www.scala-lang.org/download/" class="text-button">Install</a><a href="https://scastie.scala-lang.org" class="text-button">Playground</a><a href="https://index.scala-lang.org" class="text-button">Find A Library</a><a href="https://www.scala-lang.org/community/" class="text-button">Community</a><a href="https://www.scala-lang.org/blog/" class="text-button">Blog</a><span id="theme-toggle" class="icon-button"></span><span id="mobile-menu-toggle" class="icon-button hamburger"></span></div></div><div id="mobile-menu"><div class="mobile-menu-header body-small"><span class="mobile-menu-logo"><span id="project-logo" class="project-logo"><img src="project-logo/logo.svg"></img></span><span id="dark-project-logo" class="project-logo"><img src="project-logo/logo_dark.svg"></img></span><span class="project-name h300">Scala 3 Reference</span></span><button id="mobile-menu-close" class="icon-button close"></button></div><div class="mobile-menu-container body-medium"><input id="mobile-scaladoc-searchbar-input" class="scaladoc-searchbar-input" type="search" placeholder="Find anything"></input><a href="https://docs.scala-lang.org/" class="mobile-menu-item">Learn</a><a href="https://www.scala-lang.org/download/" class="mobile-menu-item">Install</a><a href="https://scastie.scala-lang.org" class="mobile-menu-item">Playground</a><a href="https://index.scala-lang.org" class="mobile-menu-item">Find A Library</a><a href="https://www.scala-lang.org/community/" class="mobile-menu-item">Community</a><a href="https://www.scala-lang.org/blog/" class="mobile-menu-item">Blog</a><span id="mobile-theme-toggle" class="mobile-menu-item mode"></span></div></div><span id="mobile-sidebar-toggle" class="floating-button"></span><div id="leftColumn" class="body-small"><div class="switcher-container"><a id="docs-nav-button" class="switcher h100 selected" href="index.html">Docs</a></div><nav id="docs-nav" class="side-menu"><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="new-types/index.html"><span>New Types</span></a></span><div class="ni n1 "><span class="nh de"><a href="new-types/intersection-types.html"><span>Intersection Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="new-types/union-types.html"><span>Union Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="new-types/type-lambdas.html"><span>Type Lambdas</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="new-types/match-types.html"><span>Match Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="new-types/dependent-function-types.html"><span>Dependent Function Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="new-types/polymorphic-function-types.html"><span>Polymorphic Function Types</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="enums/index.html"><span>Enums</span></a></span><div class="ni n1 "><span class="nh de"><a href="enums/enums.html"><span>Enumerations</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="enums/adts.html"><span>Algebraic Data Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="enums/desugarEnums.html"><span>Translation of Enums and ADTs</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="contextual/index.html"><span>Contextual Abstractions</span></a></span><div class="ni n1 "><span class="nh de"><a href="contextual/givens.html"><span>Given Instances</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/using-clauses.html"><span>Using Clauses</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/context-bounds.html"><span>Context Bounds</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/given-imports.html"><span>Importing Givens</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/extension-methods.html"><span>Extension Methods</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/right-associative-extension-methods.html"><span>Right-Associative Extension Methods: Details</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/type-classes.html"><span>Implementing Type classes</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/derivation.html"><span>Type Class Derivation</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/derivation-macro.html"><span>How to write a type class `derived` method using macros</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/multiversal-equality.html"><span>Multiversal Equality</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/context-functions.html"><span>Context Functions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/conversions.html"><span>Implicit Conversions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/by-name-context-parameters.html"><span>By-Name Context Parameters</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="contextual/relationship-implicits.html"><span>Relationship with Scala 2 Implicits</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="metaprogramming/index.html"><span>Metaprogramming</span></a></span><div class="ni n1 "><span class="nh de"><a href="metaprogramming/inline.html"><span>Inline</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/compiletime-ops.html"><span>Compile-time operations</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/macros.html"><span>Macros</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/staging.html"><span>Run-Time Multi-Stage Programming</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/reflection.html"><span>Reflection</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/tasty-inspect.html"><span>TASTy Inspection</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="metaprogramming/simple-smp.html"><span>The Meta-theory of Symmetric Metaprogramming</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="other-new-features/index.html"><span>Other New Features</span></a></span><div class="ni n1 "><span class="nh de"><a href="other-new-features/trait-parameters.html"><span>Trait Parameters</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/transparent-traits.html"><span>Transparent Traits and Classes</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/creator-applications.html"><span>Universal Apply Methods</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/export.html"><span>Export Clauses</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/opaques.html"><span>Opaque Type Aliases</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/opaques-details.html"><span>Opaque Type Aliases: More Details</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/open-classes.html"><span>Open Classes</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/parameter-untupling.html"><span>Parameter Untupling</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/kind-polymorphism.html"><span>Kind Polymorphism</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/matchable.html"><span>The Matchable Trait</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/threadUnsafe-annotation.html"><span>The @threadUnsafe annotation</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/targetName.html"><span>The @targetName annotation</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/control-syntax.html"><span>New Control Syntax</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/indentation.html"><span>Optional Braces</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/safe-initialization.html"><span>Safe Initialization</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/type-test.html"><span>TypeTest</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/experimental-defs.html"><span>Experimental Definitions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="other-new-features/binary-literals.html"><span>Binary Integer Literals</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="changed-features/index.html"><span>Other Changed Features</span></a></span><div class="ni n1 "><span class="nh de"><a href="changed-features/numeric-literals.html"><span>Numeric Literals</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/structural-types.html"><span>Programmatic Structural Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/operators.html"><span>Rules for Operators</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/wildcards.html"><span>Wildcard Arguments in Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/imports.html"><span>Imports</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/type-inference.html"><span>Changes in Type Inference</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/implicit-resolution.html"><span>Changes in Implicit Resolution</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/implicit-conversions.html"><span>Implicit Conversions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/overload-resolution.html"><span>Changes in Overload Resolution</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/match-syntax.html"><span>Match Expressions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/vararg-splices.html"><span>Vararg Splices</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/pattern-bindings.html"><span>Pattern Bindings</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/pattern-matching.html"><span>Option-less pattern matching</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/eta-expansion.html"><span>Automatic Eta Expansion</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/compiler-plugins.html"><span>Changes in Compiler Plugins</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/lazy-vals-init.html"><span>Lazy Vals Initialization</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/main-functions.html"><span>Main Methods</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="changed-features/interpolation-escapes.html"><span>Escapes in interpolations</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="dropped-features/index.html"><span>Dropped Features</span></a></span><div class="ni n1 "><span class="nh de"><a href="dropped-features/delayed-init.html"><span>Dropped: DelayedInit</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/macros.html"><span>Dropped: Scala 2 Macros</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/existential-types.html"><span>Dropped: Existential Types</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/type-projection.html"><span>Dropped: General Type Projection</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/do-while.html"><span>Dropped: Do-While</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/procedure-syntax.html"><span>Dropped: Procedure Syntax</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/package-objects.html"><span>Dropped: Package Objects</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/early-initializers.html"><span>Dropped: Early Initializers</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/class-shadowing.html"><span>Dropped: Class Shadowing</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/limit22.html"><span>Dropped: Limit 22</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/xml.html"><span>Dropped: XML Literals</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/symlits.html"><span>Dropped: Symbol Literals</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/auto-apply.html"><span>Dropped: Auto-Application</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/weak-conformance.html"><span>Dropped: Weak Conformance</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/nonlocal-returns.html"><span>Deprecated: Nonlocal Returns</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/this-qualifier.html"><span>Dropped: private[this] and protected[this]</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="dropped-features/wildcard-init.html"><span>Dropped: Wildcard Initializer</span></a></span></div></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="experimental/index.html"><span>Experimental</span></a></span><div class="ni n1 "><span class="nh de"><a href="experimental/canthrow.html"><span>CanThrow Capabilities</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/erased-defs.html"><span>Erased Definitions</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/named-typeargs.html"><span>Named Type Arguments</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/numeric-literals.html"><span>Numeric Literals</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/explicit-nulls.html"><span>Explicit Nulls</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/main-annotation.html"><span>MainAnnotation</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/cc.html"><span>Capture Checking</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="experimental/tupled-function.html"><span>Tupled Function</span></a></span></div></div><div class="ni n0 "><span class="nh de"><a href="syntax.html"><span>Scala 3 Syntax Summary</span></a></span></div><div class="ni n0"><span class="nh de"><button class="ar icon-button "></button><a href="language-versions/index.html"><span>Language Versions</span></a></span><div class="ni n1 "><span class="nh de"><a href="language-versions/source-compatibility.html"><span>Source Compatibility</span></a></span></div><div class="ni n1 "><span class="nh de"><a href="language-versions/binary-compatibility.html"><span>Binary Compatibility</span></a></span></div></div><div class="ni n0 "><span class="nh de"><a href="soft-modifier.html"><span>Soft Keywords</span></a></span></div><div class="ni n0 "><span class="nh de"><a href="features-classification.html"><span>A Classification of Proposed Language Features</span></a></span></div></nav></div><div id="footer" class="body-small"><div class="left-container">Generated with</div><div class="right-container"><a href="https://github.com/scala/scala3"><button class="icon-button gh"></button></a><a href="https://discord.com/invite/scala"><button class="icon-button discord"></button></a><a href="https://twitter.com/scala_lang"><button class="icon-button twitter"></button></a><div class="text">Copyright (c) 2002-2024, LAMP/EPFL</div></div><div class="text-mobile">Copyright (c) 2002-2024, LAMP/EPFL</div></div><div id="scaladoc-searchBar"></div><div id="main"><div class="breadcrumbs container"><a href="index.html">Scala 3 Reference</a></div><div id="content" class="body-medium"><div><div id="content-wrapper">
<div class="site-container">
<div id="site-header"></div>
<main>
<header>
<a class="text-button with-link body-small" href="https://github.com/scala/scala3/edit/language-reference-stable/docs/_docs/reference/overview.md">Edit this page on GitHub</a>
<h1 class="h600">Scala 3 Reference</h1>
</header>
<p class="body-large first-p">Scala 3 implements many language changes and improvements over Scala 2. In this reference, we discuss design decisions and present important differences compared to Scala 2.</p>
<section id="goals-1">
<h2 class="h500"><a href="#goals-1" class="anchor"></a>Goals</h2>
<p>The language redesign was guided by three main goals:</p>
<ul>
<li>Strengthen Scala's foundations. Make the full programming language compatible with the foundational work on the <a href="https://infoscience.epfl.ch/record/227176/files/soundness_oopsla16.pdf">DOT calculus</a> and apply the lessons learned from that work.</li>
<li>Make Scala easier and safer to use. Tame powerful constructs such as implicits to provide a gentler learning curve. Remove warts and puzzlers.</li>
<li>Further improve the consistency and expressiveness of Scala's language constructs.</li>
</ul>
<p>Corresponding to these goals, the language changes fall into seven categories: (1) Core constructs to strengthen foundations, (2) simplifications and (3) <a href="#restrictions">restrictions</a>, to make the language easier and safer to use, (4) <a href="#dropped-constructs">dropped constructs</a> to make the language smaller and more regular, (5) <a href="#changes">changed constructs</a> to remove warts, and increase consistency and usability, (6) <a href="#new-constructs">new constructs</a> to fill gaps and increase expressiveness, (7) a new, principled approach to metaprogramming that replaces <a href="https://docs.scala-lang.org/overviews/macros/overview.html">Scala 2 experimental macros</a>.</p>
</section>
<section id="essential-foundations-2">
<h2 class="h500"><a href="#essential-foundations-2" class="anchor"></a>Essential Foundations</h2>
<p>These new constructs directly model core features of DOT, higher-kinded types, and the <a href="https://infoscience.epfl.ch/record/229878/files/simplicitly_1.pdf">SI calculus for implicit resolution</a>.</p>
<ul>
<li><a href="new-types/intersection-types.html">Intersection types</a>, replacing compound types,</li>
<li><a href="new-types/union-types.html">Union types</a>,</li>
<li><a href="new-types/type-lambdas.html">Type lambdas</a>, replacing encodings using structural types and type projection.</li>
<li><a href="contextual/context-functions.html">Context functions</a>, offering abstraction over given parameters.</li>
</ul>
</section>
<section id="simplifications-2">
<h2 class="h500"><a href="#simplifications-2" class="anchor"></a>Simplifications</h2>
<p>These constructs replace existing constructs with the aim of making the language safer and simpler to use, and to promote uniformity in code style.</p>
<ul>
<li><a href="other-new-features/trait-parameters.html">Trait parameters</a> replace <a href="dropped-features/early-initializers.html">early initializers</a> with a more generally useful construct.</li>
<li><a href="contextual/givens.html">Given instances</a> replace implicit objects and defs, focussing on intent over mechanism.</li>
<li><a href="contextual/using-clauses.html">Using clauses</a> replace implicit parameters, avoiding their ambiguities.</li>
<li><a href="contextual/extension-methods.html">Extension methods</a> replace implicit classes with a clearer and simpler mechanism.</li>
<li><a href="other-new-features/opaques.html">Opaque type aliases</a> replace most uses of value classes while guaranteeing the absence of boxing.</li>
<li><a href="dropped-features/package-objects.html">Top-level definitions</a> replace package objects, dropping syntactic boilerplate.</li>
<li><a href="other-new-features/export.html">Export clauses</a> provide a simple and general way to express aggregation, which can replace the previous facade pattern of package objects inheriting from classes.</li>
<li><a href="changed-features/vararg-splices.html">Vararg splices</a> now use the form <code>xs*</code> in function arguments and patterns instead of <code>xs: _*</code> and <code>xs @ _*</code>,</li>
<li><a href="other-new-features/creator-applications.html">Universal apply methods</a> allow using simple function call syntax instead of <code>new</code> expressions. <code>new</code> expressions stay around as a fallback for the cases where creator applications cannot be used.</li>
</ul>
<p>With the exception of <a href="dropped-features/early-initializers.html">early initializers</a> and old-style vararg patterns, all superseded constructs continue to be available in Scala 3.0. The plan is to deprecate and phase them out later.</p>
<p>Value classes (superseded by opaque type aliases) are a special case. There are currently no deprecation plans for value classes, since we might bring them back in a more general form if they are supported natively by the JVM as is planned by <a href="https://openjdk.java.net/projects/valhalla/">project Valhalla</a>.</p>
</section>
<section id="restrictions-2">
<h2 class="h500"><a href="#restrictions-2" class="anchor"></a>Restrictions</h2>
<p>These constructs are restricted to make the language safer.</p>
<ul>
<li><a href="contextual/conversions.html">Implicit Conversions</a>: there is only one way to define implicit conversions instead of many, and potentially surprising implicit conversions require a language import.</li>
<li><a href="contextual/given-imports.html">Given Imports</a>: implicits now require a special form of import, to make the import clearly visible.</li>
<li><a href="dropped-features/type-projection.html">Type Projection</a>: only classes can be used as prefix <code>C</code> of a type projection <code>C#A</code>. Type projection on abstract types is no longer supported since it is unsound.</li>
<li><a href="contextual/multiversal-equality.html">Multiversal Equality</a>: implement an "opt-in" scheme to rule out nonsensical comparisons with <code>==</code> and <code>!=</code>.</li>
<li><a href="changed-features/operators.html">infix</a>: make method application syntax uniform across code bases.</li>
</ul>
<p>Unrestricted implicit conversions continue to be available in Scala 3.0, but will be deprecated and removed later. Unrestricted versions of the other constructs in the list above are available only under <code>-source 3.0-migration</code>.</p>
</section>
<section id="dropped-constructs-2">
<h2 class="h500"><a href="#dropped-constructs-2" class="anchor"></a>Dropped Constructs</h2>
<p>These constructs are proposed to be dropped without a new construct replacing them. The motivation for dropping these constructs is to simplify the language and its implementation.</p>
<ul>
<li><a href="dropped-features/delayed-init.html">DelayedInit</a>,</li>
<li><a href="dropped-features/existential-types.html">Existential types</a>,</li>
<li><a href="dropped-features/procedure-syntax.html">Procedure syntax</a>,</li>
<li><a href="dropped-features/class-shadowing.html">Class shadowing</a>,</li>
<li><a href="dropped-features/xml.html">XML literals</a>,</li>
<li><a href="dropped-features/symlits.html">Symbol literals</a>,</li>
<li><a href="dropped-features/auto-apply.html">Auto application</a>,</li>
<li><a href="dropped-features/weak-conformance.html">Weak conformance</a>,</li>
<li>Compound types (replaced by <a href="new-types/intersection-types.html">Intersection types</a>),</li>
<li><a href="https://github.com/scala/scala3/pull/4311">Auto tupling</a> (implemented, but not merged).</li>
</ul>
<p>The date when these constructs are dropped varies. The current status is:</p>
<ul>
<li>Not implemented at all:
<ul>
<li>DelayedInit, existential types, weak conformance.</li>
</ul></li>
<li>Supported under <code>-source 3.0-migration</code>:
<ul>
<li>procedure syntax, class shadowing, symbol literals, auto application, auto tupling in a restricted form.</li>
</ul></li>
<li>Supported in 3.0, to be deprecated and phased out later:
<ul>
<li><a href="dropped-features/xml.html">XML literals</a>, compound types.</li>
</ul></li>
</ul>
</section>
<section id="changes-2">
<h2 class="h500"><a href="#changes-2" class="anchor"></a>Changes</h2>
<p>These constructs have undergone changes to make them more regular and useful.</p>
<ul>
<li><a href="changed-features/structural-types.html">Structural Types</a>: They now allow pluggable implementations, which greatly increases their usefulness. Some usage patterns are restricted compared to the status quo.</li>
<li><a href="changed-features/pattern-matching.html">Name-based pattern matching</a>: The existing undocumented Scala 2 implementation has been codified in a slightly simplified form.</li>
<li><a href="changed-features/eta-expansion.html">Automatic Eta expansion</a>: Eta expansion is now performed universally also in the absence of an expected type. The postfix <code>_</code> operator is thus made redundant. It will be deprecated and dropped after Scala 3.0.</li>
<li><a href="changed-features/implicit-resolution.html">Implicit Resolution</a>: The implicit resolution rules have been cleaned up to make them more useful and less surprising. Implicit scope is restricted to no longer include package prefixes.</li>
</ul>
<p>Most aspects of old-style implicit resolution are still available under <code>-source 3.0-migration</code>. The other changes in this list are applied unconditionally.</p>
</section>
<section id="new-constructs-2">
<h2 class="h500"><a href="#new-constructs-2" class="anchor"></a>New Constructs</h2>
<p>These are additions to the language that make it more powerful or pleasant to use.</p>
<ul>
<li><a href="enums/enums.html">Enums</a> provide concise syntax for enumerations and <a href="enums/adts.html">algebraic data types</a>.</li>
<li><a href="other-new-features/parameter-untupling.html">Parameter untupling</a> avoids having to use <code>case</code> for tupled parameter destructuring.</li>
<li><a href="new-types/dependent-function-types.html">Dependent function types</a> generalize dependent methods to dependent function values and types.</li>
<li><a href="new-types/polymorphic-function-types.html">Polymorphic function types</a> generalize polymorphic methods to polymorphic function values and types. <em>Current status</em>: There is a proposal and a merged prototype implementation, but the implementation has not been finalized (it is notably missing type inference support).</li>
<li><a href="other-new-features/kind-polymorphism.html">Kind polymorphism</a> allows the definition of operators working equally on types and type constructors.</li>
<li><a href="other-new-features/targetName.html"><code>@targetName</code> annotations</a> make it easier to interoperate with code written in other languages and give more flexibility for avoiding name clashes.</li>
</ul>
</section>
<section id="metaprogramming-2">
<h2 class="h500"><a href="#metaprogramming-2" class="anchor"></a>Metaprogramming</h2>
<p>The following constructs together aim to put metaprogramming in Scala on a new basis. So far, metaprogramming was achieved by a combination of macros and libraries such as <a href="https://github.com/milessabin/shapeless">Shapeless</a> that were in turn based on some key macros. Current Scala 2 macro mechanisms are a thin veneer on top of the current Scala 2 compiler, which makes them fragile and in many cases impossible to port to Scala 3.</p>
<p>It's worth noting that macros were never included in the <a href="https://scala-lang.org/files/archive/spec/2.13/">Scala 2 language specification</a> and were so far made available only under an <code>-experimental</code> flag. This has not prevented their widespread usage.</p>
<p>To enable porting most uses of macros, we are experimenting with the advanced language constructs listed below. These designs are more provisional than the rest of the proposed language constructs for Scala 3.0. There might still be some changes until the final release. Stabilizing the feature set needed for metaprogramming is our first priority.</p>
<ul>
<li><a href="new-types/match-types.html">Match Types</a> allow computation on types.</li>
<li><a href="metaprogramming/inline.html">Inline</a> provides by itself a straightforward implementation of some simple macros and is at the same time an essential building block for the implementation of complex macros.</li>
<li><a href="metaprogramming/macros.html">Quotes and Splices</a> provide a principled way to express macros and staging with a unified set of abstractions.</li>
<li><a href="contextual/derivation.html">Type class derivation</a> provides an in-language implementation of the <code>Gen</code> macro in Shapeless and other foundational libraries. The new implementation is more robust, efficient and easier to use than the macro.</li>
<li><a href="contextual/by-name-context-parameters.html">By-name context parameters</a> provide a more robust in-language implementation of the <code>Lazy</code> macro in <a href="https://github.com/milessabin/shapeless">Shapeless</a>.</li>
</ul>
</section>
<section id="see-also-1">
<h2 class="h500"><a href="#see-also-1" class="anchor"></a>See Also</h2>
<p><a href="features-classification.html">A classification of proposed language features</a> is an expanded version of this page that adds the status (i.e. relative importance to be a part of Scala 3, and relative urgency when to decide this) and expected migration cost of each language construct.</p>
</section>
</main>
<div class="divider"></div>
<nav class="arrow-navigation" aria-label="Page navigation">
<div>
<span class="body-small">Next</span> <a rel="next" href="new-types/index.html" aria-keyshortcuts="Right" class="body-medium"> <span class="body-medium">New Types</span> </a>
</div>
</nav>
</div>
</div></div><div id="toc" class="body-small"><div id="toc-container"><span class="toc-title h200">In this article</span><nav class="toc-nav"><ul class="toc-list"><li><a href="#goals-1">Goals</a></li><li><a href="#essential-foundations-2">Essential Foundations</a></li><li><a href="#simplifications-2">Simplifications</a></li><li><a href="#restrictions-2">Restrictions</a></li><li><a href="#dropped-constructs-2">Dropped Constructs</a></li><li><a href="#changes-2">Changes</a></li><li><a href="#new-constructs-2">New Constructs</a></li><li><a href="#metaprogramming-2">Metaprogramming</a></li><li><a href="#see-also-1">See Also</a></li></ul></nav></div></div></div><div id="footer" class="body-small mobile-footer"><div class="left-container">Generated with</div><div class="right-container"><a href="https://github.com/scala/scala3"><button class="icon-button gh"></button></a><a href="https://discord.com/invite/scala"><button class="icon-button discord"></button></a><a href="https://twitter.com/scala_lang"><button class="icon-button twitter"></button></a><div class="text">Copyright (c) 2002-2024, LAMP/EPFL</div></div><div class="text-mobile">Copyright (c) 2002-2024, LAMP/EPFL</div></div></div></div></body></html>