@@ -33,8 +33,8 @@ object Logger {
3333The ` Config ` object contains a definition of the ** inline value** ` logging ` .
3434This means that ` logging ` is treated as a _ constant value_ , equivalent to its
3535right-hand side ` false ` . The right-hand side of such an ` inline val ` must itself
36- be a [ constant expression] ( https://scala-lang.org/files/archive/spec/2.12/06-expressions.html#constant-expressions ) . Used in this
37- way, ` inline ` is equivalent to Java and Scala 2's ` final ` . Note that ` final ` , meaning
36+ be a [ constant expression] ( https://scala-lang.org/files/archive/spec/2.12/06-expressions.html#constant-expressions ) .
37+ Used in this way, ` inline ` is equivalent to Java and Scala 2's ` final ` . Note that ` final ` , meaning
3838_ inlined constant_ , is still supported in Dotty, but will be phased out.
3939
4040The ` Logger ` object contains a definition of the ** inline method** ` log ` . This
@@ -272,8 +272,8 @@ The scrutinee `x` is examined statically and the inline match is reduced
272272accordingly returning the corresponding value (with the type specialized due to
273273the ` <: ` in the return type). This example performs a simple type test over the
274274scrutinee. The type can have a richer structure like the simple ADT below.
275- ` toInt ` matches the structure of a number in Church-encoding and _ computes _ the
276- corresponding integer.
275+ ` toInt ` matches the structure of a number in [ Church-encoding] ( https://en.wikipedia.org/wiki/Church_encoding )
276+ and _ computes _ the corresponding integer.
277277
278278``` scala
279279trait Nat
@@ -319,11 +319,11 @@ the singleton type `2`.
319319
320320#### ` erasedValue `
321321
322- We have seen so far inline methods that take terms (tuples and integers) as
322+ So far we have seen inline methods that take terms (tuples and integers) as
323323parameters. What if we want to base case distinctions on types instead? For
324324instance, one would like to be able to write a function ` defaultValue ` , that,
325- given a type ` T ` returns optionally the default value of ` T ` , if it exists. In
326- fact, we can already express this using rewrite match expressions and a simple
325+ given a type ` T ` , returns optionally the default value of ` T ` , if it exists.
326+ We can already express this using rewrite match expressions and a simple
327327helper function, ` scala.compiletime.erasedValue ` , which is defined as follows:
328328
329329``` scala
@@ -333,7 +333,7 @@ erased def erasedValue[T]: T = ???
333333The ` erasedValue ` function _ pretends_ to return a value of its type argument
334334` T ` . In fact, it would always raise a ` NotImplementedError ` exception when
335335called. But the function can in fact never be called, since it is declared
336- ` erased ` , so can be only used at compile-time during type checking.
336+ ` erased ` , so can only be used at compile-time during type checking.
337337
338338Using ` erasedValue ` , we can then define ` defaultValue ` as follows:
339339
@@ -360,10 +360,11 @@ Then:
360360 val dAny : None .type = defaultValue[Any ]
361361```
362362
363- As another example, consider the type-level version of ` toNat ` above the we call
364- ` toIntT ` : given a _ type_ representing a Peano number, return the integer _ value_
365- corresponding to it. Consider the definitions of numbers as in the _ Inline
366- Match_ section aboce. Here's how ` toIntT ` can be defined:
363+ As another example, consider the type-level version of ` toInt ` below:
364+ given a _ type_ representing a [ Peano number] ( https://wiki.haskell.org/Peano_numbers ) ,
365+ return the integer _ value_ corresponding to it.
366+ Consider the definitions of numbers as in the _ Inline
367+ Match_ section above. Here is how ` toIntT ` can be defined:
367368
368369``` scala
369370inline def toIntT [N <: Nat ] <: Int = inline scala.compiletime.erasedValue[N ] match {
0 commit comments