diff --git a/docs/docs/reference/contextual/import-implied.md b/docs/docs/reference/contextual/import-implied.md index efca5558a259..560f2adbe1b9 100644 --- a/docs/docs/reference/contextual/import-implied.md +++ b/docs/docs/reference/contextual/import-implied.md @@ -39,7 +39,7 @@ import delegate A.{for TC} This imports any delegate in `A` that has a type which conforms tp `TC`. There can be several bounding types following a `for` and bounding types can contain wildcards. For instance, assuming the object ```scala -object Instances { +object Delegates { delegate intOrd for Ordering[Int] delegate [T: Ordering] listOrd for Ordering[List[T]] delegate ec for ExecutionContext = ... @@ -48,7 +48,7 @@ object Instances { ``` the import ``` -import delegate Instances.{for Ordering[_], ExecutionContext} +import delegate Delegates.{for Ordering[_], ExecutionContext} ``` would import the `intOrd`, `listOrd`, and `ec` delegates but leave out the `im` delegate, since it fits none of the specified bounds. diff --git a/docs/docs/reference/features-classification.md b/docs/docs/reference/features-classification.md index 3201a6359e00..98473219cd6b 100644 --- a/docs/docs/reference/features-classification.md +++ b/docs/docs/reference/features-classification.md @@ -21,7 +21,7 @@ These new constructs directly model core features of DOT, higher-kinded types, a - [Type lambdas](https://dotty.epfl.ch/docs/reference/new-types/type-lambdas.html), replacing encodings using structural types and type projection. - [Context Queries](https://dotty.epfl.ch/docs/reference/contextual/query-types.html) - (_aka_ implicit function types) offering abstraction over inferable parameters. + (_aka_ implicit function types) offering abstraction over given parameters. **Status: essential** @@ -36,9 +36,9 @@ Since these are additions, there's generally no migration cost for old code. An These constructs replace existing constructs with the aim of making the language safer and simpler to use, and to promote uniformity in code style. - [Trait Parameters](https://dotty.epfl.ch/docs/reference/other-new-features/trait-parameters.html) replace [early initializers](https://dotty.epfl.ch/docs/reference/dropped-features/early-initializers.html) with a more generally useful construct. - - [Implied Instances](https://dotty.epfl.ch/docs/reference/contextual/instance-defs.html) + - [Delegates](https://dotty.epfl.ch/docs/reference/contextual/instance-defs.html) replace implicit objects and defs, focussing on intent over mechanism. - - [Inferable parameters](https://dotty.epfl.ch/docs/reference/contextual/inferable-params.html) replace implicit parameters, avoiding their ambiguities. + - [Given Clauses](https://dotty.epfl.ch/docs/reference/contextual/inferable-params.html) replace implicit parameters, avoiding their ambiguities. - [Extension Methods](https://dotty.epfl.ch/docs/reference/contextual/extension-methods.html) replace implicit classes with a clearer and simpler mechanism. - [Opaque Type Aliases](https://dotty.epfl.ch/docs/reference/other-new-features/opaques.html) replace most uses of value classes while guaranteeing absence of boxing. @@ -71,7 +71,7 @@ For the next several versions, old features will remain available and deprecatio These constructs are restricted to make the language safer. - [Implicit Conversions](https://dotty.epfl.ch/docs/reference/contextual/conversions.html): there is only one way to define implicit conversions instead of many, and potentially surprising implicit conversions require a language import. - - [Implied Imports](https://dotty.epfl.ch/docs/reference/contextual/import-implied.html): implicits now require a special form of import, to make the import clearly visible. + - [Delegate Imports](https://dotty.epfl.ch/docs/reference/contextual/import-implied.html): implicits now require a special form of import, to make the import clearly visible. - [Type Projection](https://dotty.epfl.ch/docs/reference/dropped-features/type-projection.html): only classes can be used as prefix `C` of a type projection `C#A`. Type projection on abstract types is no longer supported since it is unsound. - [Multiversal Equality](https://dotty.epfl.ch/docs/reference/contextual/multiversal-equality.html) implements an "opt-in" scheme to rule out nonsensical comparisons with `==` and `!=`. - [@infix and @alpha](https://github.com/lampepfl/dotty/pull/5975) diff --git a/docs/docs/reference/metaprogramming/inline.md b/docs/docs/reference/metaprogramming/inline.md index ead86a97be20..059601928387 100644 --- a/docs/docs/reference/metaprogramming/inline.md +++ b/docs/docs/reference/metaprogramming/inline.md @@ -79,11 +79,11 @@ In the `true` case the code will be rewritten to: def factorial(n: BigInt): BigInt = { val msg = s"factorial($n)" println(s"${" " * indent}start $msg") - Logger.inline$indent += indentSetting + Logger.inline$indent_=(indent.+(indentSetting)) val result = if (n == 0) 1 else n * factorial(n - 1) - Logger.inline$indent -= indentSetting + Logger.inline$indent_=(indent.-(indentSetting)) println(s"${" " * indent}$msg = $result") result } @@ -91,7 +91,8 @@ def factorial(n: BigInt): BigInt = { Note, that the by-value parameter is evaluated only once, per the usual Scala semantics, by binding the value and reusing the `msg` through the body of -`factorial`. +`factorial`. Also, note the special handling of setting to the private var +`indent` by generating the setter method `def inline$indent_=`. ### Recursive Inline Methods diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index afef8aa35467..33e1f12e4147 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -586,13 +586,4 @@ val a: Int = defaultOf("int") val b: String = defaultOf("string") ``` -### Let - -`scala.tasty.reflect.utils.TreeUtils` offers a method `let` that allows us to -bind the `rhs` to a `val` and use it in `body`. Its definition is shown below: - -```scala -def let(rhs: Term)(body: Ident => Term): Term -``` - [More details](./macros-spec.html) \ No newline at end of file diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index 866b783fc7a9..b303462e7f0b 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -139,6 +139,20 @@ def collectPatternVariables(tree: Tree)(implicit ctx: Context): List[Symbol] = { A `TreeTraverser` extends a `TreeAccumulator` and performs the same traversal but without returning any value. Finally a `TreeMap` performs a transformation. +#### Let + +`scala.tasty.reflect.utils.TreeUtils` also offers a method `let` that allows us +to bind the `rhs` to a `val` and use it in `body`. Additionally, `lets` binds +the given `terms` to names and use them in the `body`. Their type definitions +are shown below: + +```scala +def let(rhs: Term)(body: Ident => Term): Term = ... + +def lets(terms: List[Term])(body: List[Term] => Term): Term = ... +``` + + ## TASTy Reflect API TASTy Reflect provides the following types: diff --git a/docs/docs/reference/overview.md b/docs/docs/reference/overview.md index a1e904cafb79..5657bb941e2c 100644 --- a/docs/docs/reference/overview.md +++ b/docs/docs/reference/overview.md @@ -25,8 +25,8 @@ These new constructs directly model core features of DOT, higher-kinded types, a - [Union types](https://dotty.epfl.ch/docs/reference/new-types/union-types.html), - [Type lambdas](https://dotty.epfl.ch/docs/reference/new-types/type-lambdas.html), replacing encodings using structural types and type projection. - - [Implicit Function Types](https://dotty.epfl.ch/docs/reference/contextual/query-types.html) - offering abstraction over implicit parameters. + - [Context Queries](https://dotty.epfl.ch/docs/reference/contextual/query-types.html) + (_aka_ implicit function types) offering abstraction over implicit parameters. ## Simplifications