@@ -73,6 +73,30 @@ aligns with Java's syntax.
7373For more information please read our documentation on
7474[ Wildcards] ( https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html ) .
7575
76+ # Syntax Change: Contextual Abstractions
77+
78+ We reconsider the syntax for contextual abstractions introducing ` delegates `
79+ (formerly known as ` implied ` ). ` delegate ` , in the context of contextual
80+ abstraction means that we declare a _ representative of a type_ . We use
81+ ` delegate ` as a noun. Note that this change is solely syntactical/grammatical
82+ and its motivation is to give a clearer meaning to those _ canonical_ values of
83+ certain types (like ` Ord[Int] ` ), that serve for synthesizing arguments to
84+ ` given ` clauses.
85+
86+ ``` scala
87+ delegate IntOrd for Ord [Int ] {
88+ def compare (x : Int , y : Int ) =
89+ if (x < y) - 1 else if (x > y) + 1 else 0
90+ }
91+ ```
92+
93+ ``` scala
94+ delegate ListOrd [T ] for Ord [List [T ]] given (ord : Ord [T ]) {
95+ ```
96+
97+ For more information, the documentation has been updated as part of the relevant
98+ PR [# 6649 ](https:// github.com/ lampepfl/ dotty/ pull/ 6649 )
99+
76100## Polymorphic function types
77101
78102We add preliminary support for _polymorphic function types_. Nowadays , when we
@@ -117,33 +141,33 @@ recovered by using the newly-introduced `@threadUnsafe`.
117141For more information please read our documentation on the
118142[threadUnsafe annotation](https:// dotty.epfl.ch/ docs/ reference/ other- new - features/ threadUnsafe- annotation.html).
119143
120- ## Introducing ` for ` clauses for importing implied imports by type
144+ ## Introducing `for` clauses for importing delegate imports by type
121145
122- Since implied instances can be anonymous it is not always practical to import
146+ Since delegate instances can be anonymous it is not always practical to import
123147them by their name, and wildcard imports are typically used instead. By - type
124148imports provide a more specific alternative to wildcard imports, which makes it
125149clearer what is imported. Example :
126150
127151 ```scala
128- import implied A .{for TC }
152+ import delegate A .{for TC }
129153```
130154
131- This imports any implied instance in ` A ` that has a type which conforms tp ` TC ` .
155+ This imports any delegate instance in `A` that has a type which conforms tp `TC`.
132156There can be several bounding types following a `for` and bounding types can
133157contain wildcards.
134158For instance, assuming the object
135159
136160```scala
137- object Instances {
138- implied intOrd for Ordering [Int ]
139- implied [T : Ordering ] listOrd for Ordering [List [T ]]
140- implied ec for ExecutionContext = ...
141- implied im for Monoid [Int ]
161+ object Delegates {
162+ delegate intOrd for Ordering [Int ]
163+ delegate [T : Ordering ] listOrd for Ordering [List [T ]]
164+ delegate ec for ExecutionContext = ...
165+ delegate im for Monoid [Int ]
142166}
143167```
144168the import
145169```
146- import implied Instances.{for Ordering[_], ExecutionContext}
170+ import delegate Instances .{for Ordering [_ ], ExecutionContext }
147171```
148172would import the `intOrd` , `listOrd` , and `ec` instances but leave out the `im`
149173instance, since it fits none of the specified bounds.
0 commit comments