Skip to content

Commit d7b24e7

Browse files
committed
Update docs
The new implementation does not optimize given aliases with pure paths as right hand sides to be vals anymore. The reason is that even a pure path might be expensive to compute so we might want the caching. And caching is cheap, so there's little downside. Therefore, it's attractive to go with the simpler two way choice: leave RHS as is, or wrap it in a memo.
1 parent dde3ad8 commit d7b24e7

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@ Given instances can be mapped to combinations of implicit objects, classes and i
2828
class ListOrd[T](implicit ord: Ord[T]) extends Ord[List[T]] { ... }
2929
final implicit def ListOrd[T](implicit ord: Ord[T]): ListOrd[T] = new ListOrd[T]
3030
```
31-
3. Alias givens map to implicit methods. If an alias has neither type parameters nor a given clause, its right-hand side is cached in a variable. There are two cases that can be optimized:
32-
33-
- If the right hand side is a simple reference, we can
34-
use a forwarder to that reference without caching it.
35-
- If the right hand side is more complex, but still known to be pure, we can
36-
create a `val` that computes it ahead of time.
31+
3. Alias givens map to implicit methods. If an alias has neither type parameters nor a given clause, its right-hand side is cached in a variable, unless the right hand side is a simple reference in which case we can use a forwarder to that reference without caching it.
3732

3833
Examples:
3934

4035
```scala
4136
given global as ExecutionContext = new ForkJoinContext()
42-
given config as Config = default.config
4337

4438
val ctx: Context
4539
given as Context = ctx
@@ -52,8 +46,6 @@ Given instances can be mapped to combinations of implicit objects, classes and i
5246
global$cache
5347
}
5448

55-
final implicit val config: Config = default.config
56-
5749
final implicit def Context_given = ctx
5850
```
5951

0 commit comments

Comments
 (0)