From 9e07d5e3e05cfa8f03108a9132b18a66551b8d51 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 7 Jun 2019 17:23:53 +0200 Subject: [PATCH 1/5] Tweaks to terminology in docs Remove inconsistencies between actual pages and overview pages and sidebar. --- docs/docs/reference/features-classification.md | 6 +++--- docs/docs/reference/overview.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/reference/features-classification.md b/docs/docs/reference/features-classification.md index 3201a6359e00..3b303be597ad 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 implicit parameters. **Status: essential** @@ -38,7 +38,7 @@ These constructs replace existing constructs with the aim of making the language - [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) 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. + - [Import Implied](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/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 From ed514bb5569bf7bedf9226f70722a774246c7dea Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Sat, 8 Jun 2019 11:26:23 +0200 Subject: [PATCH 2/5] Move subsection for lets on the correct place --- docs/docs/reference/metaprogramming/macros.md | 9 --------- .../reference/metaprogramming/tasty-reflect.md | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) 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: From 9e8f0fe64e1b7672d6939315cedd3077609ce68b Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 11 Jun 2019 07:26:48 +0200 Subject: [PATCH 3/5] Fix implied leftover at docs --- docs/docs/reference/contextual/import-implied.md | 4 ++-- docs/docs/reference/features-classification.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 3b303be597ad..a3a99c8b0133 100644 --- a/docs/docs/reference/features-classification.md +++ b/docs/docs/reference/features-classification.md @@ -36,7 +36,7 @@ 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. - [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. @@ -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. - - [Import Implied](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) From dff7d88921ae681a6c41de005306c002b0461324 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 11 Jun 2019 07:41:24 +0200 Subject: [PATCH 4/5] Fix inline example with missing getter method --- docs/docs/reference/metaprogramming/inline.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 From 7f9b55effca28a49a8629fe2096d04b69da69485 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 11 Jun 2019 07:43:43 +0200 Subject: [PATCH 5/5] More fixes --- docs/docs/reference/features-classification.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/features-classification.md b/docs/docs/reference/features-classification.md index a3a99c8b0133..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 implicit parameters. + (_aka_ implicit function types) offering abstraction over given parameters. **Status: essential**