diff --git a/_glossary/index.md b/_glossary/index.md
index 75b5c98081..9d4d490c65 100644
--- a/_glossary/index.md
+++ b/_glossary/index.md
@@ -16,380 +16,380 @@ languages: [zh-cn]
-* #### algebraic data type
+* ### algebraic data type
A type defined by providing several alternatives, each of which comes with its own constructor. It usually comes with a way to decompose the type through pattern matching. The concept is found in specification languages and functional programming languages. Algebraic data types can be emulated in Scala with case classes.
-* #### alternative
+* ### alternative
A branch of a match expression. It has the form “`case` _pattern_ => _expression_.” Another name for alternative is _case_.
-* #### annotation
+* ### annotation
An annotation appears in source code and is attached to some part of the syntax. Annotations are computer processable, so you can use them to effectively add an extension to Scala.
-* #### anonymous class
+* ### anonymous class
An anonymous class is a synthetic subclass generated by the Scala compiler from a new expression in which the class or trait name is followed by curly braces. The curly braces contains the body of the anonymous subclass, which may be empty. However, if the name following new refers to a trait or class that contains abstract members, these must be made concrete inside the curly braces that define the body of the anonymous subclass.
-* #### anonymous function
+* ### anonymous function
Another name for [function literal](#function-literal).
-* #### apply
+* ### apply
You can apply a method, function, or closure to arguments, which means you invoke it on those arguments.
-* #### argument
+* ### argument
When a function is invoked, an argument is passed for each parameter of that function. The parameter is the variable that refers to the argument. The argument is the object passed at invocation time. In addition, applications can take (command line) arguments that show up in the `Array[String]` passed to main methods of singleton objects.
-* #### assign
+* ### assign
You can assign an object to a variable. Afterwards, the variable will refer to the object.
-* #### auxiliary constructor
+* ### auxiliary constructor
Extra constructors defined inside the curly braces of the class definition, which look like method definitions named `this`, but with no result type.
-* #### block
+* ### block
One or more expressions and declarations surrounded by curly braces. When the block evaluates, all of its expressions and declarations are processed in order, and then the block returns the value of the last expression as its own value. Blocks are commonly used as the bodies of functions, [for expressions](#for-expression), `while` loops, and any other place where you want to group a number of statements together. More formally, a block is an encapsulation construct for which you can only see side effects and a result value. The curly braces in which you define a class or object do not, therefore, form a block, because fields and methods (which are defined inside those curly braces) are visible from the outside. Such curly braces form a template.
-* #### bound variable
+* ### bound variable
A bound variable of an expression is a variable that’s both used and defined inside the expression. For instance, in the function literal expression `(x: Int) => (x, y)`, both variables `x` and `y` are used, but only `x` is bound, because it is defined in the expression as an `Int` and the sole argument to the function described by the expression.
-* #### by-name parameter
+* ### by-name parameter
A parameter that is marked with a `=>` in front of the parameter type, e.g., `(x: => Int)`. The argument corresponding to a by-name parameter is evaluated not before the method is invoked, but each time the parameter is referenced by name inside the method. If a parameter is not by-name, it is by-value.
-* #### by-value parameter
+* ### by-value parameter
A parameter that is not marked with a `=>` in front of the parameter type, e.g., `(x: Int)`. The argument corresponding to a by-value parameter is evaluated before the method is invoked. By-value parameters contrast with by-name parameters.
-* #### class
+* ### class
Defined with the `class` keyword, a _class_ may either be abstract or concrete, and may be parameterized with types and values when instantiated. In `new Array[String](2)`, the class being instantiated is `Array` and the type of the value that results is `Array[String]`. A class that takes type parameters is called a _type constructor_. A type can be said to have a class as well, as in: the class of type `Array[String]` is `Array`.
-* #### closure
+* ### closure
A function object that captures free variables, and is said to be “closed” over the variables visible at the time it is created.
-* #### companion class
+* ### companion class
A class that shares the same name with a singleton object defined in the same source file. The class is the singleton object’s companion class.
-* #### companion object
+* ### companion object
A singleton object that shares the same name with a class defined in the same source file. Companion objects and classes have access to each other’s private members. In addition, any implicit conversions defined in the companion object will be in scope anywhere the class is used.
-* #### contravariant
+* ### contravariant
A _contravariant_ annotation can be applied to a type parameter of a class or trait by putting a minus sign (-) before the type parameter. The class or trait then subtypes contravariantly with—in the opposite direction as—the type annotated parameter. For example, `Function1` is contravariant in its first type parameter, and so `Function1[Any, Any]` is a subtype of `Function1[String, Any]`.
-* #### covariant
+* ### covariant
A _covariant_ annotation can be applied to a type parameter of a class or trait by putting a plus sign (+) before the type parameter. The class or trait then subtypes covariantly with—in the same direction as—the type annotated parameter. For example, `List` is covariant in its type parameter, so `List[String]` is a subtype of `List[Any]`.
-* #### currying
+* ### currying
A way to write functions with multiple parameter lists. For instance `def f(x: Int)(y: Int)` is a curried function with two parameter lists. A curried function is applied by passing several arguments lists, as in: `f(3)(4)`. However, it is also possible to write a _partial application_ of a curried function, such as `f(3)`.
-* #### declare
+* ### declare
You can _declare_ an abstract field, method, or type, which gives an entity a name but not an implementation. The key difference between declarations and definitions is that definitions establish an implementation for the named entity, declarations do not.
-* #### define
+* ### define
To _define_ something in a Scala program is to give it a name and an implementation. You can define classes, traits, singleton objects, fields, methods, local functions, local variables, _etc_. Because definitions always involve some kind of implementation, abstract members are declared not defined.
-* #### direct subclass
+* ### direct subclass
A class is a _direct subclass_ of its direct superclass.
-* #### direct superclass
+* ### direct superclass
The class from which a class or trait is immediately derived, the nearest class above it in its inheritance hierarchy. If a class `Parent` is mentioned in a class `Child`’s optional extends clause, then `Parent` is the direct superclass of `Child`. If a trait is mentioned in `Child`’s extends clause, the trait’s direct superclass is the `Child`’s direct superclass. If `Child` has no extends clause, then `AnyRef` is the direct superclass of `Child`. If a class’s direct superclass takes type parameters, for example class `Child` extends `Parent[String]`, the direct superclass of `Child` is still `Parent`, not `Parent[String]`. On the other hand, `Parent[String]` would be the direct supertype of `Child`. See [supertype](#supertype) for more discussion of the distinction between class and type.
-* #### equality
+* ### equality
When used without qualification, _equality_ is the relation between values expressed by `==`. See also [reference equality](#reference-equality).
-* #### existential type
+* ### existential type
An existential type includes references to type variables that are unknown. For example, `Array[T] forSome { type T }` is an existential type. It is an array of `T`, where `T` is some completely unknown type. All that is assumed about `T` is that it exists at all. This assumption is weak, but it means at least that an `Array[T] forSome { type T }` is indeed an array and not a banana.
-* #### expression
+* ### expression
Any bit of Scala code that yields a result. You can also say that an expression _evaluates_ to a result or _results_ in a value.
-* #### filter
+* ### filter
An `if` followed by a boolean expression in a [for expression](#for-expression). In `for(i <- 1 to 10; if i % 2 == 0)`, the filter is “`if i % 2 == 0`”. The value to the right of the `if` is the [filter expression](#filter-expression). Also known as a guard.
-* #### filter expression
+* ### filter expression
A _filter expression_ is the boolean expression following an `if` in a [for expression](#for-expression). In `for( i <- 1 to 10 ; if i % 2 == 0)`,the filter expression is “`i % 2 == 0`”.
-* #### first-class function
+* ### first-class function
Scala supports _first-class functions_, which means you can express functions in function literal syntax, i.e., `(x: Int) => x + 1`, and that functions can be represented by objects, which are called [function values](#function-value).
-* #### for comprehension
+* ### for comprehension
A _for comprehension_ is a type of [for expression](#for-expression) that creates a new collection. For each iteration of the `for` comprehension, the [yield](#yield) clause defines an element of the new collection. For example, `for (i <- (0 until 2); j <- (2 until 4)) yield (i, j)` returns the collection `Vector((0,2), (0,3), (1,2), (1,3))`.
-* #### for expression
+* ### for expression
A _for expression_ is either a [for loop](#for-loop), which iterates over one or more collections, or a [for comprehension](#for-comprehension), which builds a new collection from the elements of one or more collections. A `for` expression is built up of [generators](#generator), [filters](#filter), variable definitions, and (in the case of [for comprehensions](#for-comprehension)) a [yield](#yield) clause.
-* #### for loop
+* ### for loop
A _for loop_ is a type of [for expression](#for-expression) that loops over one or more collections. Since `for` loops return unit, they usually produce side-effects. For example, `for (i <- 0 until 100) println(i)` prints the numbers 0 through 99.
-* #### free variable
+* ### free variable
A _free variable_ of an expression is a variable that’s used inside the expression but not defined inside the expression. For instance, in the function literal expression `(x: Int) => (x, y)`, both variables `x` and `y` are used, but only `y` is a free variable, because it is not defined inside the expression.
-* #### function
+* ### function
A _function_ can be [invoked](#invoke) with a list of arguments to produce a result. A function has a parameter list, a body, and a result type. Functions that are members of a class, trait, or singleton object are called [methods](#method). Functions defined inside other functions are called [local functions](#local-function). Functions with the result type of `Unit` are called [procedures](#procedure). Anonymous functions in source code are called [function literals](#function-literal). At run time, function literals are instantiated into objects called [function values](#function-value).
-* #### function literal
+* ### function literal
A function with no name in Scala source code, specified with _function literal_ syntax. For example, `(x: Int, y: Int) => x + y`.
-* #### function value
+* ### function value
A function object that can be invoked just like any other function. A _function value_’s class extends one of the `FunctionN` traits (e.g., `Function0`, `Function1`) from package `scala`, and is usually expressed in source code via [function literal](#function-literal) syntax. A function value is “invoked” when its apply method is called. A function value that captures free variables is a [closure](#closure).
-* #### functional style
+* ### functional style
The _functional style_ of programming emphasizes functions and evaluation results and deemphasizes the order in which operations occur. The style is characterized by passing function values into looping methods, immutable data, methods with no side effects. It is the dominant paradigm of languages such as Haskell and Erlang, and contrasts with the [imperative style](#imperative-style).
-* #### generator
+* ### generator
A _generator_ defines a named val and assigns to it a series of values in a [for expression](#for-expression). For example, in `for(i <- 1 to 10)`, the generator is “`i <- 1 to 10`”. The value to the right of the `<-` is the [generator expression](#generator-expression).
-* #### generator expression
+* ### generator expression
A _generator expression_ generates a series of values in a [for expression](#for-expression). For example, in `for(i <- 1 to 10)`, the generator expression is “`1 to 10`”.
-* #### generic class
+* ### generic class
A class that takes type parameters. For example, because `scala.List` takes a type parameter, `scala.List` is a _generic class_.
-* #### generic trait
+* ### generic trait
A trait that takes type parameters. For example, because trait `scala.collection.Set` takes a type parameter, it is a _generic trait_.
-* #### guard
+* ### guard
See [filter](#filter).
-* #### helper function
+* ### helper function
A function whose purpose is to provide a service to one or more other functions nearby. Helper functions are often implemented as local functions.
-* #### helper method
+* ### helper method
A [helper function](#helper-function) that’s a member of a class. Helper methods are often private.
-* #### immutable
+* ### immutable
An object is _immutable_ if its value cannot be changed after it is created in any way visible to clients. Objects may or may not be immutable.
-* #### imperative style
+* ### imperative style
The _imperative style_ of programming emphasizes careful sequencing of operations so that their effects happen in the right order. The style is characterized by iteration with loops, mutating data in place, and methods with side effects. It is the dominant paradigm of languages such as C, C++, C# and Java, and contrasts with the [functional style](#functional-style).
-* #### initialize
+* ### initialize
When a variable is defined in Scala source code, you must _initialize_ it with an object.
-* #### instance
+* ### instance
An _instance_, or class instance, is an object, a concept that exists only at run time.
-* #### instantiate
+* ### instantiate
To _instantiate_ a class is to make a new object from the class, an action that happens only at run time.
-* #### invariant
+* ### invariant
_Invariant_ is used in two ways. It can mean a property that always holds true when a data structure is well-formed. For example, it is an invariant of a sorted binary tree that each node is ordered before its right subnode, if it has a right subnode. Invariant is also sometimes used as a synonym for nonvariant: “class `Array` is invariant in its type parameter.”
-* #### invoke
+* ### invoke
You can _invoke_ a method, function, or closure _on_ arguments, meaning its body will be executed with the specified arguments.
-* #### JVM
+* ### JVM
The _JVM_ is the Java Virtual Machine, or [runtime](#runtime), that hosts a running Scala program.
-* #### literal
+* ### literal
`1`, `"One"`, and `(x: Int) => x + 1` are examples of _literals_. A literal is a shorthand way to describe an object, where the shorthand exactly mirrors the structure of the created object.
-* #### local function
+* ### local function
A _local function_ is a `def` defined inside a block. To contrast, a `def` defined as a member of a class, trait, or singleton object is called a [method](#method).
-* #### local variable
+* ### local variable
A _local variable_ is a `val` or `var` defined inside a block. Although similar to [local variables](#local-variable), parameters to functions are not referred to as local variables, but simply as parameters or “variables” without the “local.”
-* #### member
+* ### member
A _member_ is any named element of the template of a class, trait, or singleton object. A member may be accessed with the name of its owner, a dot, and its simple name. For example, top-level fields and methods defined in a class are members of that class. A trait defined inside a class is a member of its enclosing class. A type defined with the type keyword in a class is a member of that class. A class is a member of the package in which is it defined. By contrast, a local variable or local function is not a member of its surrounding block.
-* #### message
+* ### message
Actors communicate with each other by sending each other _messages_. Sending a message does not interrupt what the receiver is doing. The receiver can wait until it has finished its current activity and its invariants have been reestablished.
-* #### meta-programming
+* ### meta-programming
Meta-programming software is software whose input is itself software. Compilers are meta-programs, as are tools like `scaladoc`. Meta-programming software is required in order to do anything with an annotation.
-* #### method
+* ### method
A _method_ is a function that is a member of some class, trait, or singleton object.
-* #### mixin
+* ### mixin
_Mixin_ is what a trait is called when it is being used in a mixin composition. In other words, in “`trait Hat`,” `Hat` is just a trait, but in “`new Cat extends AnyRef with Hat`,” `Hat` can be called a mixin. When used as a verb, “mix in” is two words. For example, you can _mix_ traits _in_ to classes or other traits.
-* #### mixin composition
+* ### mixin composition
The process of mixing traits into classes or other traits. _Mixin composition_ differs from traditional multiple inheritance in that the type of the super reference is not known at the point the trait is defined, but rather is determined anew each time the trait is mixed into a class or other trait.
-* #### modifier
+* ### modifier
A keyword that qualifies a class, trait, field, or method definition in some way. For example, the `private` modifier indicates that a class, trait, field, or method being defined is private.
-* #### multiple definitions
+* ### multiple definitions
The same expression can be assigned in _multiple definitions_ if you use the syntax `val v1, v2, v3 = exp`.
-* #### nonvariant
+* ### nonvariant
A type parameter of a class or trait is by default _nonvariant_. The class or trait then does not subtype when that parameter changes. For example, because class `Array` is nonvariant in its type parameter, `Array[String]` is neither a subtype nor a supertype of `Array[Any]`.
-* #### operation
+* ### operation
In Scala, every _operation_ is a method call. Methods may be invoked in _operator notation_, such as `b + 2`, and when in that notation, `+` is an _operator_.
-* #### parameter
+* ### parameter
Functions may take zero to many _parameters_. Each parameter has a name and a type. The distinction between parameters and arguments is that arguments refer to the actual objects passed when a function is invoked. Parameters are the variables that refer to those passed arguments.
-* #### parameterless function
+* ### parameterless function
A function that takes no parameters, which is defined without any empty parentheses. Invocations of parameterless functions may not supply parentheses. This supports the [uniform access principle](#uniform-access-principle), which enables the `def` to be changed into a `val` without requiring a change to client code.
-* #### parameterless method
+* ### parameterless method
A _parameterless method_ is a parameterless function that is a member of a class, trait, or singleton object.
-* #### parametric field
+* ### parametric field
A field defined as a class parameter.
-* #### partially applied function
+* ### partially applied function
A function that’s used in an expression and that misses some of its arguments. For instance, if function `f` has type `Int => Int => Int`, then `f` and `f(1)` are _partially applied functions_.
-* #### path-dependent type
+* ### path-dependent type
A type like `swiss.cow.Food`. The `swiss.cow` part is a path that forms a reference to an object. The meaning of the type is sensitive to the path you use to access it. The types `swiss.cow.Food` and `fish.Food`, for example, are different types.
-* #### pattern
+* ### pattern
In a `match` expression alternative, a _pattern_ follows each `case` keyword and precedes either a _pattern guard_ or the `=>` symbol.
-* #### pattern guard
+* ### pattern guard
In a `match` expression alternative, a _pattern guard_ can follow a [pattern](#pattern). For example, in “`case x if x % 2 == 0 => x + 1`”, the pattern guard is “`if x % 2 == 0`”. A case with a pattern guard will only be selected if the pattern matches and the pattern guard yields true.
-* #### predicate
+* ### predicate
A _predicate_ is a function with a `Boolean` result type.
-* #### primary constructor
+* ### primary constructor
The main constructor of a class, which invokes a superclass constructor, if necessary, initializes fields to passed values, and executes any top-level code defined between the curly braces of the class. Fields are initialized only for value parameters not passed to the superclass constructor, except for any that are not used in the body of the class and can therefore be optimized away.
-* #### procedure
+* ### procedure
A _procedure_ is a function with result type of `Unit`, which is therefore executed solely for its side effects.
-* #### reassignable
+* ### reassignable
A variable may or may not be _reassignable_. A `var` is reassignable while a `val` is not.
-* #### recursive
+* ### recursive
A function is _recursive_ if it calls itself. If the only place the function calls itself is the last expression of the function, then the function is [tail recursive](#tail-recursive).
-* #### reference
+* ### reference
A _reference_ is the Java abstraction of a pointer, which uniquely identifies an object that resides on the JVM’s heap. Reference type variables hold references to objects, because reference types (instances of `AnyRef`) are implemented as Java objects that reside on the JVM’s heap. Value type variables, by contrast, may sometimes hold a reference (to a boxed wrapper type) and sometimes not (when the object is being represented as a primitive value). Speaking generally, a Scala variable [refers](#refers) to an object. The term “refers” is more abstract than “holds a reference.” If a variable of type `scala.Int` is currently represented as a primitive Java `int` value, then that variable still refers to the `Int` object, but no reference is involved.
-* #### reference equality
+* ### reference equality
_Reference equality_ means that two references identify the very same Java object. Reference equality can be determined, for reference types only, by calling `eq` in `AnyRef`. (In Java programs, reference equality can be determined using `==` on Java [reference types](#reference-type).)
-* #### reference type
+* ### reference type
A _reference type_ is a subclass of `AnyRef`. Instances of reference types always reside on the JVM’s heap at run time.
-* #### referential transparency
+* ### referential transparency
A property of functions that are independent of temporal context and have no side effects. For a particular input, an invocation of a referentially transparent function can be replaced by its result without changing the program semantics.
-* #### refers
+* ### refers
A variable in a running Scala program always _refers_ to some object. Even if that variable is assigned to `null`, it conceptually refers to the `Null` object. At runtime, an object may be implemented by a Java object or a value of a primitive type, but Scala allows programmers to think at a higher level of abstraction about their code as they imagine it running. See also [reference](#reference).
-* #### refinement type
+* ### refinement type
A type formed by supplying a base type with a number of members inside curly braces. The members in the curly braces refine the types that are present in the base type. For example, the type of “animal that eats grass” is `Animal { type SuitableFood = Grass }`.
-* #### result
+* ### result
An expression in a Scala program yields a _result_. The result of every expression in Scala is an object.
-* #### result type
+* ### result type
A method’s _result type_ is the type of the value that results from calling the method. (In Java, this concept is called the return type.)
-* #### return
+* ### return
A function in a Scala program _returns_ a value. You can call this value the [result](#result) of the function. You can also say the function _results in_ the value. The result of every function in Scala is an object.
-* #### runtime
+* ### runtime
The Java Virtual Machine, or [JVM](#jvm), that hosts a running Scala program. Runtime encompasses both the virtual machine, as defined by the Java Virtual Machine Specification, and the runtime libraries of the Java API and the standard Scala API. The phrase at run time (with a space between run and time) means when the program is running, and contrasts with compile time.
-* #### runtime type
+* ### runtime type
The type of an object at run time. To contrast, a [static type](#static-type) is the type of an expression at compile time. Most runtime types are simply bare classes with no type parameters. For example, the runtime type of `"Hi"` is `String`, and the runtime type of `(x: Int) => x + 1` is `Function1`. Runtime types can be tested with `isInstanceOf`.
-* #### script
+* ### script
A file containing top level definitions and statements, which can be run directly with `scala` without explicitly compiling. A script must end in an expression, not a definition.
-* #### selector
+* ### selector
The value being matched on in a `match` expression. For example, in “`s match { case _ => }`”, the selector is `s`.
-* #### self type
+* ### self type
A _self type_ of a trait is the assumed type of `this`, the receiver, to be used within the trait. Any concrete class that mixes in the trait must ensure that its type conforms to the trait’s self type. The most common use of self types is for dividing a large class into several traits (as described in Chapter 29 of [Programming in Scala](https://www.artima.com/shop/programming_in_scala)).
-* #### semi-structured data
+* ### semi-structured data
XML data is semi-structured. It is more structured than a flat binary file or text file, but it does not have the full structure of a programming language’s data structures.
-* #### serialization
+* ### serialization
You can _serialize_ an object into a byte stream which can then be saved to a file or transmitted over the network. You can later _deserialize_ the byte stream, even on different computer, and obtain an object that is the same as the original serialized object.
-* #### shadow
+* ### shadow
A new declaration of a local variable _shadows_ one of the same name in an enclosing scope.
-* #### signature
+* ### signature
_Signature_ is short for [type signature](#type-signature).
-* #### singleton object
+* ### singleton object
An object defined with the object keyword. Each singleton object has one and only one instance. A singleton object that shares its name with a class, and is defined in the same source file as that class, is that class’s [companion object](#companion-object). The class is its [companion class](#companion-class). A singleton object that doesn’t have a companion class is a [standalone object](#standalone-object).
-* #### standalone object
+* ### standalone object
A [singleton object](#singleton-object) that has no [companion class](#companion-class).
-* #### statement
+* ### statement
An expression, definition, or import, _i.e._, things that can go into a template or a block in Scala source code.
-* #### static type
+* ### static type
See [type](#type).
-* #### structural type
+* ### structural type
A [refinement type](#refinement-type) where the refinements are for members not in the base type. For example, `{ def close(): Unit }` is a structural type, because the base type is `AnyRef`, and `AnyRef` does not have a member named `close`.
-* #### subclass
+* ### subclass
A class is a _subclass_ of all of its [superclasses](#superclass) and [supertraits](#supertrait).
-* #### subtrait
+* ### subtrait
A trait is a _subtrait_ of all of its [supertraits](#supertrait).
-* #### subtype
+* ### subtype
The Scala compiler will allow any of a type’s _subtypes_ to be used as a substitute wherever that type is required. For classes and traits that take no type parameters, the subtype relationship mirrors the subclass relationship. For example, if class `Cat` is a subclass of abstract class `Animal`, and neither takes type parameters, type `Cat` is a subtype of type `Animal`. Likewise, if trait `Apple` is a subtrait of trait `Fruit`, and neither takes type parameters, type `Apple` is a subtype of type `Fruit`. For classes and traits that take type parameters, however, variance comes into play. For example, because abstract class `List` is declared to be covariant in its lone type parameter (i.e., `List` is declared `List[+A]`), `List[Cat]` is a subtype of `List[Animal]`, and `List[Apple]` a subtype of `List[Fruit]`. These subtype relationships exist even though the class of each of these types is `List`. By contrast, because `Set` is not declared to be covariant in its type parameter (i.e., `Set` is declared `Set[A]` with no plus sign), `Set[Cat]` is not a subtype of `Set[Animal]`. A subtype should correctly implement the contracts of its supertypes, so that the Liskov Substitution Principle applies, but the compiler only verifies this property at the level of type checking.
-* #### superclass
+* ### superclass
A class’s _superclasses_ include its direct superclass, its direct superclass’s direct superclass, and so on, all the way up to `Any`.
-* #### supertrait
+* ### supertrait
A class’s or trait’s _supertraits_, if any, include all traits directly mixed into the class or trait or any of its superclasses, plus any supertraits of those traits.
-* #### supertype
+* ### supertype
A type is a _supertype_ of all of its subtypes.
-* #### synthetic class
+* ### synthetic class
A synthetic class is generated automatically by the compiler rather than being written by hand by the programmer.
-* #### tail recursive
+* ### tail recursive
A function is _tail recursive_ if the only place the function calls itself is the last operation of the function.
-* #### target typing
+* ### target typing
_Target typing_ is a form of type inference that takes into account the type that’s expected. In `nums.filter((x) => x > 0)`, for example, the Scala compiler infers type of `x` to be the element type of `nums`, because the `filter` method invokes the function on each element of `nums`.
-* #### template
+* ### template
A _template_ is the body of a class, trait, or singleton object definition. It defines the type signature, behavior and initial state of the class, trait, or object.
-* #### trait
+* ### trait
A _trait_, which is defined with the `trait` keyword, is like an abstract class that cannot take any value parameters and can be “mixed into” classes or other traits via the process known as [mixin composition](#mixin-composition). When a trait is being mixed into a class or trait, it is called a [mixin](#mixin). A trait may be parameterized with one or more types. When parameterized with types, the trait constructs a type. For example, `Set` is a trait that takes a single type parameter, whereas `Set[Int]` is a type. Also, `Set` is said to be “the trait of” type `Set[Int]`.
-* #### type
+* ### type
Every variable and expression in a Scala program has a _type_ that is known at compile time. A type restricts the possible values to which a variable can refer, or an expression can produce, at run time. A variable or expression’s type can also be referred to as a _static type_ if necessary to differentiate it from an object’s [runtime type](#runtime-type). In other words, “type” by itself means static type. Type is distinct from class because a class that takes type parameters can construct many types. For example, `List` is a class, but not a type. `List[T]` is a type with a free type parameter. `List[Int]` and `List[String]` are also types (called ground types because they have no free type parameters). A type can have a “[class](#class)” or “[trait](#trait).” For example, the class of type `List[Int]` is `List`. The trait of type `Set[String]` is `Set`.
-* #### type constraint
+* ### type constraint
Some [annotations](#annotation) are _type constraints_, meaning that they add additional limits, or constraints, on what values the type includes. For example, `@positive` could be a type constraint on the type `Int`, limiting the type of 32-bit integers down to those that are positive. Type constraints are not checked by the standard Scala compiler, but must instead be checked by an extra tool or by a compiler plugin.
-* #### type constructor
+* ### type constructor
A class or trait that takes type parameters.
-* #### type parameter
+* ### type parameter
A parameter to a generic class or generic method that must be filled in by a type. For example, class `List` is defined as “`class List[T] { . . . `”, and method `identity`, a member of object `Predef`, is defined as “`def identity[T](x:T) = x`”. The `T` in both cases is a type parameter.
-* #### type signature
+* ### type signature
A method’s _type signature_ comprises its name, the number, order, and types of its parameters, if any, and its result type. The type signature of a class, trait, or singleton object comprises its name, the type signatures of all of its members and constructors, and its declared inheritance and mixin relations.
-* #### uniform access principle
+* ### uniform access principle
The _uniform access principle_ states that variables and parameterless functions should be accessed using the same syntax. Scala supports this principle by not allowing parentheses to be placed at call sites of parameterless functions. As a result, a parameterless function definition can be changed to a `val`, or _vice versa_, without affecting client code.
-* #### unreachable
+* ### unreachable
At the Scala level, objects can become _unreachable_, at which point the memory they occupy may be reclaimed by the runtime. Unreachable does not necessarily mean unreferenced. Reference types (instances of `AnyRef`) are implemented as objects that reside on the JVM’s heap. When an instance of a reference type becomes unreachable, it indeed becomes unreferenced, and is available for garbage collection. Value types (instances of `AnyVal`) are implemented as both primitive type values and as instances of Java wrapper types (such as `java.lang.Integer`), which reside on the heap. Value type instances can be boxed (converted from a primitive value to a wrapper object) and unboxed (converted from a wrapper object to a primitive value) throughout the lifetime of the variables that refer to them. If a value type instance currently represented as a wrapper object on the JVM’s heap becomes unreachable, it indeed becomes unreferenced, and is available for garbage collection. But if a value type currently represented as a primitive value becomes unreachable, then it does not become unreferenced, because it does not exist as an object on the JVM’s heap at that point of time. The runtime may reclaim memory occupied by unreachable objects, but if an Int, for example, is implemented at run time by a primitive Java int that occupies some memory in the stack frame of an executing method, then the memory for that object is “reclaimed” when the stack frame is popped as the method completes. Memory for reference types, such as `Strings`, may be reclaimed by the JVM’s garbage collector after they become unreachable.
-* #### unreferenced
+* ### unreferenced
See [unreachable](#unreachable).
-* #### value
+* ### value
The result of any computation or expression in Scala is a _value_, and in Scala, every value is an object. The term value essentially means the image of an object in memory (on the JVM’s heap or stack).
-* #### value type
+* ### value type
A _value type_ is any subclass of `AnyVal`, such as `Int`, `Double`, or `Unit`. This term has meaning at the level of Scala source code. At runtime, instances of value types that correspond to Java primitive types may be implemented in terms of primitive type values or instances of wrapper types, such as `java.lang.Integer`. Over the lifetime of a value type instance, the runtime may transform it back and forth between primitive and wrapper types (_i.e._, to box and unbox it).
-* #### variable
+* ### variable
A named entity that refers to an object. A variable is either a `val` or a `var`. Both `val`s and `var`s must be initialized when defined, but only `var`s can be later reassigned to refer to a different object.
-* #### variance
+* ### variance
A type parameter of a class or trait can be marked with a _variance_ annotation, either [covariant](#covariant) (+) or [contravariant](#contravariant) (-). Such variance annotations indicate how subtyping works for a generic class or trait. For example, the generic class `List` is covariant in its type parameter, and thus `List[String]` is a subtype of `List[Any]`. By default, _i.e._, absent a `+` or `-` annotation, type parameters are [nonvariant](#nonvariant).
-* #### yield
+* ### yield
An expression can _yield_ a result. The `yield` keyword designates the result of a [for comprehension](#for-comprehension).
diff --git a/_sass/layout/glossary.scss b/_sass/layout/glossary.scss
index e55ef1c9aa..8346ea1b40 100644
--- a/_sass/layout/glossary.scss
+++ b/_sass/layout/glossary.scss
@@ -55,7 +55,7 @@
}
li {
- h4 {
+ h3 {
text-transform: none;
margin-bottom: 2px;
font-weight: $font-black;
diff --git a/_zh-cn/glossary/index.md b/_zh-cn/glossary/index.md
index 210c56108b..055eff8026 100644
--- a/_zh-cn/glossary/index.md
+++ b/_zh-cn/glossary/index.md
@@ -16,381 +16,381 @@ language: zh-cn
-* #### 代数数据类型(algebraic data type)
+* ### 代数数据类型(algebraic data type)
通过提供若干个带有独立构造器的备选项来定义的类型。它一般通过模式匹配的方式来结构类型,在规约语言和函数式编程语言中常见到这个概念。Scala可通过样例类来模拟代数数据类型。
-* #### 备选项(alternative)
+* ### 备选项(alternative)
match表达式的一个分支,形如 “`case` _pattern_ => _expression_”。备选项的别名是 _案例_(_case_)。
-* #### 注解(annotation)
+* ### 注解(annotation)
注解一般出现在源码中,并附加到语法的某个部分。注解对于计算机来说都是可处理的,所以可以用来有效的增加Scala扩展。
-* #### 匿名类(anonymous class)
+* ### 匿名类(anonymous class)
匿名类是由Scala编译器根据一种new表达式生成的合成子类,这种new表达式由类名或特质名后面紧跟一对花括号组成。花括号内包含了匿名子类的构造体,可为空,不过一旦跟在new后面名称指向的特质或类包含了抽象成员,则这些抽象成员就必须在其匿名子类的构造体内具化,即在花括号内要实现这些成员。
-* #### 匿名函数(anonymous function)
+* ### 匿名函数(anonymous function)
[函数字面量](#函数字面量function-literal)的另一种叫法。
-* #### 应用(apply)
+* ### 应用(apply)
方法、函数或闭包应用于参数,意思是说通过这些实参来调用方法、函数或闭包。
-* #### 实参(argument)
+* ### 实参(argument)
在函数调用过程中实参被传给函数的各个参数,其中参数就是指向实参的变量,实参则是调用发生时被传入的对象。另外,应用程序都可以获取被传入单例对象的main方法且类型为`Array[String]`的实参(来自命令行)。
-* #### 赋值(assign)
+* ### 赋值(assign)
可把对象赋值给变量,之后,变量就会指向对象。
-* #### 辅助构造器(auxiliary constructor)
+* ### 辅助构造器(auxiliary constructor)
在类定义体花括号里面定义的所有附加构造器,其形似名为`this`但无结果类型的方法定义。
-* #### 块(block)
+* ### 块(block)
被花括号围起来的一个或多个表达式和声明。求值块的时候,块内所有表达式和声明会被顺序处理,然后会返回最后一个表达式的值作为其自身的值。块通常被用来作为构造体,诸如函数、[for表达式](#for表达式for-expression)、`while`循环以及其他任何需要把语句组织到一起的地方,都会用到块。更正式点说,块是一个只其副作用和结果值对外可见的封装构造体。因此,类或对象的花括号是不会形成块的,因其内部定义字段和方法均对外可见。这样的花括号形成的是模板。
-* #### 绑定变量(bound variable)
+* ### 绑定变量(bound variable)
表达式的绑定变量是定义和使用都在表达式内部的变量。例如,在函数字面量表达式`(x: Int) => (x, y)`里面,`x`和`y`都被用到了,但只有`x`被绑定了,因为它在表达式中被定义为一个`Int`变量,并且它也是表达式所描述函数的唯一实参。
-* #### 传名参数(by-name parameter)
+* ### 传名参数(by-name parameter)
参数类型前面带有`=>`的参数,如`(x: => Int)`。传名参数对应的实参求值不在方法被调用前,而是在每次方法通过名称引用到参数的时候。参数若不是传名的,则定是传值的。
-* #### 传值参数(by-value parameter)
+* ### 传值参数(by-value parameter)
参数类型前面不带`=>`的参数,如`(x: Int)`。传值参数对应的实参是在方法调用前被求值的。传值参数是相对传名参数而言的。
-* #### 类(class)
+* ### 类(class)
通过关键字`class`来定义的类,可抽象可具体,且在实例化时可用类型和值对其进行参数化处理。比如`new Array[String](2)`,被实例化的类是`Array`,产生的值类型为`Array[String]`。带有类型参数的类被称为 _类型构造器_ ,也可说成是类型具有类属性,如:类型`Array[String]`具有的类属性是`Array`。
-* #### 闭包(closure)
+* ### 闭包(closure)
可以捕获自由变量,或者说"关闭"函数创建时可见变量的函数对象。
-* #### 伴生类(companion class)
+* ### 伴生类(companion class)
和定义在相同源文件中的单例对象共享同一个名称的类,这样的类就叫做那个单例对象的伴生类。
-* #### 伴生对象(companion object)
+* ### 伴生对象(companion object)
和定义在相同源文件中的类共享同一个名称的单例对象。伴生对象和伴生类具备访问彼此私有成员的能力。另外,类不管被用在何处,其伴生对象中定义的任何隐式转换都在其作用域内。
-* #### 逆变(contravariant)
+* ### 逆变(contravariant)
逆变标注可应用于类或特质的类型参数上,把减号(-)置于类型参数前即可。标注为逆变后类或特质的子类型将逆向(向相反的方向)协变于类型标注的参数。比如,`Function1`的第一个类型参数就是逆变的,所以`Function1[Any, Any]`是`Function1[String, Any]`的子类。
-* #### 协变(covariant)
-协变标注可应用于类或特质的类型参数上,把加号(+)置于类型参数前即可。标注为协变后类或特质的子类型将正向(向相同的方向)协变于类型标注的参数。比如,`List`的类型参数是协变的,所以`List[String]`是`List[Any]`的子类。
+* ### 协变(covariant)
+协变标注可应用于类或特质的类型参数上,把加号(+)置于类型参数前即可。标注为协变后类或特质的子类型将正向(向相同的方向)协变于类型标注的参数。比如,`List`的类型参数是协变的,所以`List[String]`是`List[Any]`的子类。
-* #### 柯里化(currying)
+* ### 柯里化(currying)
把函数写成多个参数列表的方式。例如:`def f(x: Int)(y: Int)`是一个带有两个参数列表的柯里化函数。应用柯里化函数时需传入若干个实参列表,像`f(3)(4)`这样。不过也可以写成柯里化函数的 _部分应用_(partial application),像`f(3)`这样。
-* #### 声明(declare)
+* ### 声明(declare)
可以通过 _声明_ 抽象的字段、方法或类型来赋给实体一个名称,但是没有具体实现。声明和定义最关键的差异就是定义会为命名实体创建具体实现,而声明则不会。
-* #### 定义(define)
+* ### 定义(define)
在Scala程序中若提到 _定义_ 什么东西,就是说给它赋个名称并给出实现。可以定义的东西包括类、特质、单例对象、字段、方法、局部函数、局部变量等。由于提到定义常常会涉及到某种具体实现,故而抽象成员应为声明而非定义。
-* #### 直接子类(direct subclass)
+* ### 直接子类(direct subclass)
类是其 _直接子类_ 的直接超类。
-* #### 直接超类(direct superclass)
+* ### 直接超类(direct superclass)
从某个类直接衍生出类或特质,或者说在继承层级结构最接近自己的上层的某个类,这样的类就是直接超类。若类`Child`的可选的extends子句中含有类`Parent`,则`Parent`就是`Child`的直接超类。若`Child`的可选extends子句中含有特质,则特质的直接超类也是`Child`的直接超类。若`Child`没有extends子句,则`AnyRef`就是`Child`的直接超类。若类的直接超类带有类型参数,比如`Child extends Parent[String]`,`Child`的直接超类依旧是`Parent`,而不是`Parent[String]`。另一方面,`Parent[String]`应该叫做`Child`的直接超类型。参见[超类型](#超类型supertype)了解更多关于类和类型间的区别。
-* #### 相等性(equality)
+* ### 相等性(equality)
在没有条件限制的情况下使用时,_相等性_ 就是`==`所表达的两个值之间的关系。参见[引用相等性](#引用相等性reference-equality)。
-* #### 存在类型(existential type)
+* ### 存在类型(existential type)
存在类型包含未知类型变量的引用。比如:`Array[T] forSome { type T }`是个存在类型,是`T`的数组,而`T`是某个完全未知的类型,关于`T`唯一能够假定的是它是确定存在的。尽管这个假定很虚,但是至少意味着`Array[T] forSome { type T }`确实是个数组,而不是香蕉什么的东西。
-* #### 表达式(expression)
+* ### 表达式(expression)
任何能够得到结果的Scala代码,也可说成表达式求值为某个结果或结果为某个值。
-* #### 过滤器(filter)
+* ### 过滤器(filter)
[for表达式](#for表达式for-expression)中的`if`及跟在其后的布尔表达式。在`for(i <- 1 to 10; if i % 2 == 0)`中,过滤器为"`if i % 2 == 0`"。`if`右边的值就是[过滤器表达式](#过滤器表达式filter-expression),也称为守卫。
-* #### 过滤器表达式(filter expression)
+* ### 过滤器表达式(filter expression)
过滤器表达式就是[for表达式](#for表达式for-expression)里面跟在`if`后面的布尔表达式。`for( i <- 1 to 10 ; if i % 2 == 0)`的过滤器表达式为"`i % 2 == 0`"。
-* #### 头等函数(first-class function)
+* ### 头等函数(first-class function)
Scala支持 _头等函数_ ,意味着可以通过函数字面量语法来表达函数。如:`(x: Int) => x + 1`,并且函数可由对象来表达,叫做[函数值](#函数值function-value)。
-* #### for推解式(for comprehension)
+* ### for推解式(for comprehension)
_for推解式_ 是[for表达式](#for表达式for-expression)的一种,一般用来创建新的集合。对`for`推解式的每次迭代,[yield](#产生yield)子句都会定义新集合的一个元素。比如:`for (i <- (0 until 2); j <- (2 until 4)) yield (i, j)`将返回集合`Vector((0,2), (0,3), (1,2), (1,3))`。
-* #### for表达式(for expression)
+* ### for表达式(for expression)
_for表达式_ 要么是个[for循环](#for循环for-loop),可以迭代一个或多个集合,要么是个[for推解式](#for推解式for-comprehension),可以从一个或多个集合的元素中推解出一个新的集合。`for`表达式建于[生成器](#生成器generator)、[过滤器](#过滤器filter)、变量定义和[yield](#产生yield)子句(针对[for推解式](#for推解式for-comprehension))基础之上,
-* #### for循环(for loop)
+* ### for循环(for loop)
_for循环_ 是[for表达式](#for表达式for-expression)的一种,一般用来循环迭代一个或多个集合。因为`for`循环返回unit,所以经常被用来产生副作用。比如:`for (i <- 0 until 100) println(i)`打印数字0到99。
-* #### 自由变量(free variable)
+* ### 自由变量(free variable)
一个表达式的 _自由变量_ 指的是在表达式中使用但不定义在其中的变量。例如,在函数字面量表达式`(x: Int) => (x, y)`中,变量`x`和`y`都被用到了,但只有`y`是自由变量,因其未在表达式中定义。
-* #### 函数(function)
+* ### 函数(function)
_函数_ 可通过一列实参来[调用](#调用invoke)然后产生结果。函数一般具有参数列表、函数体和结果类型。作为类、特质或单例对象的函数叫做[方法](#方法method)。定义在其他函数内部的函数叫做[局部函数](#局部函数local-function)。结果类型为`Unit`的函数叫做[过程](#过程procedure)。源码里面的匿名函数叫做[函数字面量](#函数字面量function-literal)。运行时,函数字面量被实例化为对象,叫做[函数值](#函数值function-value)。
-* #### 函数字面量(function literal)
+* ### 函数字面量(function literal)
在Scala源码中的无名函数,通过函数字面量语法来特别对待。比如:`(x: Int, y: Int) => x + y`。
-* #### 函数值(function value)
+* ### 函数值(function value)
可以像其他函数一样被调用的函数对象。函数值的类一般是继承了`scala`包中的`FunctionN`(比如`Function0`,`Function1`等)这类特质的其中之一,且在源码中常通过[函数字面量](#函数字面量function-literal)语法来表示。当函数值的apply方法被调用时就说这个函数值被调用。捕获自由变量的函数值为[闭包](#闭包closure)。
-* #### 函数式风格(functional style)
+* ### 函数式风格(functional style)
_函数式风格_ 编程注重函数和求值结果而非操作发生的顺序。这种风格的特征是可传递函数值给循环方法、不可变数据、方法无副作用,是像Haskell和Erlang等这些语言的主要范式,与[命令式风格](#命令式风格imperative-style)相对应。
-* #### 生成器(generator)
+* ### 生成器(generator)
生成器在[for表达式](#for表达式for-expression)中定义一个命名的val变量并赋予其一系列值。比如:`for(i <- 1 to 10)`的生成器是"`i <- 1 to 10`",`<-`右边的值是[生成器表达式](#生成器表达式generator-expression)。
-* #### 生成器表达式(generator expression)
+* ### 生成器表达式(generator expression)
生成器表达式在[for表达式](#for表达式for-expression)中生成一些列值。比如:`for(i <- 1 to 10)`的生成器表达式是"`1 to 10`"。
-* #### 泛型类(generic class)
+* ### 泛型类(generic class)
带有类型参数的类。例如,因`scala.List`带一类型参数,故其为泛型类。
-* #### 泛型特质(generic trait)
+* ### 泛型特质(generic trait)
带有类型参数的特质。例如,因`scala.collection.Set`带一类型参数,故其为泛型特质。
-* #### 守卫(guard)
+* ### 守卫(guard)
参见[过滤器](#过滤器filter).
-* #### 辅助函数(helper function)
+* ### 辅助函数(helper function)
目的是为一个或多个其他邻近函数提供服务的函数。辅助函数常实现为局部函数。
-* #### 辅助方法(helper method)
+* ### 辅助方法(helper method)
作为类成员的[辅助函数](#辅助函数helper-function)。辅助方法常为私有方法。
-* #### 不可变(immutable)
+* ### 不可变(immutable)
若对象的值在任何对客户端可见的方式下创建后不会被修改则称对象是 _不可变_ 的。对象既可以是不可变的,也可以是可变的。
-* #### 命令式风格(imperative style)
+* ### 命令式风格(imperative style)
_命令式风格_ 编程强调严谨的操作序列以令效用能在正确的顺序发生。这种风格的特征是循环迭代、适当变更数据、方法有副作用,是像C, C++, C#和Java等这些语言的主要范式,与[函数式风格](#函数式风格functional-style)相对应。
-* #### 初始化(initialize)
+* ### 初始化(initialize)
变量在Scala源码中被定义时,必须用对象对其进行初始化。
-* #### 实例(instance)
+* ### 实例(instance)
_实例_ ,或叫类实例,是个对象,是个仅在运行时存在的概念
-* #### 实例化(instantiate)
+* ### 实例化(instantiate)
_实例化_ 类是根据类创建一个新对象,是仅在运行时发生的动作。
-* #### 不变性(invariant)
+* ### 不变性(invariant)
_不变性_ 用在两个地方。首先在数据结构组织良好的情况下它可以表示某个属性始终为真。比如,若排序二叉树具有右子节点,则其各节点就会在其右子节点前完成排序,这就属于排序二叉树的不变性。其次有时不变性也作为非协变的同义词,如:"类`Array`在类型参数上具备不变性"。
-* #### 调用(invoke)
+* ### 调用(invoke)
在实参上 _调用_ 方法、函数或闭包,意即其方法体会在指定实参上执行。
-* #### Java虚拟机(JVM)
+* ### Java虚拟机(JVM)
_JVM_ 是Java虚拟机(#runtime)的缩写,或叫[运行时](#运行时runtime),是运行Scala程序的宿主。
-* #### 字面量(literal)
+* ### 字面量(literal)
`1`,`"One"`,和`(x: Int) => x + 1`是 _字面量_ 的例子,字面量是描述对象的便捷方式,便捷在这种方式正好反映了所创建对象的结构。
-* #### 局部函数(local function)
+* ### 局部函数(local function)
_局部函数_ 是块内`def`定义的,作为对比,同为`def`定义的作为类、特质或单例对象的成员则被称作[方法](#方法method)。
-* #### 局部变量(local variable)
+* ### 局部变量(local variable)
_局部变量_ 是块内`val`或`var`定义的。尽管函数参数和[局部变量](#局部变量local-variable)类似,但并不叫局部变量,而是去掉"局部"直接叫"参数"或"变量"。
-* #### 成员(member)
+* ### 成员(member)
_成员_ 是类、特质或单例对象模板中被命名的元素。成员可通过所有者名称,点及其简名访问。例如,定义在类的最顶层字段和方法是这个类的成员。定义在类中的特质是包围它的类的成员。类中通过type关键字定义的类型是这个类的成员。类是其定义所在的包的成员。相比之下,局部变量或局部函数就不是包围他们的块的成员。
-* #### 消息(message)
+* ### 消息(message)
Actor是通过给彼此之间发送 _消息_ 来进行通信的。发送消息不会打断接收者正在处理的事情,接收者可一直等到当前活动结束且其不变性被重建之后。
-* #### 元编程(meta-programming)
+* ### 元编程(meta-programming)
元编程程序是指其输入是其自身程序的程序。编译器都是元程序,像`scaladoc`这样的工具也是。要用注解做任何事都需要元编程程序。
-* #### 方法(method)
+* ### 方法(method)
_方法_ 就是类、特质或单例对象的成员函数。
-* #### 混入(mixin)
+* ### 混入(mixin)
_混入_ 就是特质用在混入组合时的名称。换言之,在"`trait Hat`"里面,`Hat`仅为特质,而"`new Cat extends AnyRef with Hat`"里面的`Hat`就可叫混入。用作动词时,"混"和"入"("mix in")是两个词。比如,可 _混_ 特质 _入_ 至类或其他特质。
-* #### 混入组合(mixin composition)
+* ### 混入组合(mixin composition)
把特质混入类或其他特质的过程。_混入组合_ 与传统的多重继承不同之处在于父级引用的类型不是在特质定义时已知的,而是在每次特质每次混入到类或其他特质时才被重新确定。
-* #### 修饰符(modifier)
+* ### 修饰符(modifier)
用来以某种方式限定类、特质、字段或方法等的定义的关键字。比如,`private`修饰符表明被定义的类、特质、字段或方法是私有的。
-* #### 多重定义(multiple definitions)
+* ### 多重定义(multiple definitions)
通过使用类似这样的语法`val v1, v2, v3 = exp`,同一个表达式根据 _多重定义_ 概念可被赋值给多个变量。
-* #### 非协变(nonvariant)
+* ### 非协变(nonvariant)
类或特质的类型参数默认是 _非协变_ 的,故而参数变化并不会子类化相应的类或特质。比如,因类`Array`非协变于其类型参数,故`Array[String]`既非`Array[Any]`之子类,亦非其超类。
-* #### 操作(operation)
+* ### 操作(operation)
在Scala中,每个 _操作_ 都是一个方法调用。方法也可以 _操作符符号_ 的方式被调用,像在`b + 2`里面符号`+`就是一个 _操作符_。
-* #### 参数(parameter)
+* ### 参数(parameter)
函数可带有零至多个 _参数_,每个参数都有名称和类型。参数与实参之间的区别在于函数调用时实参指向具体的对象,参数则是指向这些传入实参的变量。
-* #### 无参函数(parameterless function)
+* ### 无参函数(parameterless function)
不带参数的函数,其定义时没有任何空括号。无参函数可不带括号调用,这种方式符合[统一访问原则](#统一访问原则uniform-access-principle),就是在客户端不改变任何代码的情况下把`def`改成`val`。
-* #### 无参方法(parameterless method)
+* ### 无参方法(parameterless method)
_无参方法_ 就是作为类、特质或单例对象成员的无参函数。
-* #### 参数化字段(parametric field)
+* ### 参数化字段(parametric field)
定义为类参数的字段。
-* #### 偏应用函数(部分应用函数)(partially applied function)
+* ### 偏应用函数(部分应用函数)(partially applied function)
用在表达式中,省掉某些参数的函数。例如:若函数`f`的类型为`Int => Int => Int`,则`f`和`f(1)`就是 _偏应用函数_。
-* #### 路径依赖类型(path-dependent type)
+* ### 路径依赖类型(path-dependent type)
类似`swiss.cow.Food`的一种类型,`swiss.cow`部分形成一个对象引用的路径。这种类型的含义对于用来访问它的路径是敏感的,比如,`swiss.cow.Food`和`fish.Food`这两个是不同的类型。
-* #### 模式(pattern)
+* ### 模式(pattern)
在`match`表达式的某个备选项中,_模式_ 跟在`case`关键字后,先于 _模式守卫_ 或`=>`符号二者之一。
-* #### 模式守卫(pattern guard)
+* ### 模式守卫(pattern guard)
在`match`表达式的某个备选项中,_模式守卫_ 可跟在某个[模式](#模式pattern)后面。比如,"`case x if x % 2 == 0 => x + 1`"中的模式守卫为"`if x % 2 == 0`"。带有模式守卫的备选项(case)仅当其模式匹配了并且模式守卫为真的时候才会被选中。
-* #### 断言(predicate)
+* ### 断言(predicate)
断言是结果类型为`Boolean`的函数。
-* #### 主构造器(primary constructor)
+* ### 主构造器(primary constructor)
类的主要构造器,会调用超类构造器,如果有必要,也会初始化字段进行传值,并且会执行类的花括号内定义的的顶层(top-level)代码。字段仅由不传给超类构造器的值参数做初始化,那些类构造体内因未用到而被优化掉的除外。
-* #### 过程(procedure)
+* ### 过程(procedure)
_过程_ 是结果类型为`Unit`的函数,其存在的理由仅为产生副作用。
-* #### 可重新赋值(reassignable)
+* ### 可重新赋值(reassignable)
变量可以是可重新赋值的,也可以不是可重新赋值的。`var`是可重新赋值的,而`val`则不是。
-* #### 递归的(recursive)
+* ### 递归的(recursive)
若函数可调用自身就说它是 _递归的_。若函数调用自身的唯一位置是函数的最后一个表达式,则函数是[尾递归](#尾递归tail-recursive)的。
-* #### 引用(reference)
+* ### 引用(reference)
_引用_ 是指针的Java抽象,可唯一确定存在JVM堆中的对象。引用类型变量持有对象的引用,因为引用类型(`AnyRef`的实例)是存在JVM堆上的Java对象实现的。相比之下,值类型变量有时会持有一个(装箱类型的)引用,也有时(当对象表示基础类型值的时候)不会。一般说来,Scala变量[指向](#指向refers)对象。术语"指向"比"持有引用"更加抽象。如果类型为`scala.Int`的变量当前代表Java基础类型`int`的值,则这个变量仍然指向`Int`对象,但并不涉及任何引用。
-* #### 引用相等性(reference equality)
+* ### 引用相等性(reference equality)
_引用相等性_ 意思是两个引用指向同一个Java对象。引用相等性仅针对引用类型有意义,是可以通过调用`AnyRef`中的`eq`来确定的(在Java程序中,引用相等性通过在Java[引用类型](#引用类型reference-type)上调用`==`来确定)。
-* #### 引用类型(reference type)
+* ### 引用类型(reference type)
_引用类型_ 是`AnyRef`的子类。在运行时,引用类型的实例常驻JVM堆中。
-* #### 引用透明(referential transparency)
+* ### 引用透明(referential transparency)
独立于临时上下文且无副作用的函数属性。对于特定输入,引用透明函数的调用可由其结果替换而不改变程序语义。
-* #### 指向(refers)
+* ### 指向(refers)
运行的Scala程序中的变量常 _指向_ 某个对象。变量即使被赋为`null`,概念上也是指向`Null`对象。在运行时,对象可由Java对象或基础类型值来实现,不过Scala允许程序员在更高层次抽象代码以他们设想的方式运行。参见[引用](#引用reference).
-* #### 精化类型(refinement type)
+* ### 精化类型(refinement type)
通过提供基础类型及其构造体花括号内若干成员而形成的类型。花括号内的成员精细化了基础类型所体现的类型。比如,"食草动物"(animal that eats grass)的类型为`Animal { type SuitableFood = Grass }`。
A type formed by supplying a base type a number of members inside curly braces. The members in the curly braces refine the types that are present in the base type. For example, the type of “animal that eats grass” is `Animal { type SuitableFood = Grass }`.
-* #### 结果(result)
+* ### 结果(result)
Scala程序中的表达式会产生 _结果_。Scala中的每个表达式的结果都是对象。
-* #### 结果类型(result type)
+* ### 结果类型(result type)
方法的 _结果类型_ 是调用方法所产生的值的类型。(在Java中,这个概念被称为返回类型)
-* #### 返回(return)
+* ### 返回(return)
Scala程序中的函数会 _返回_ 值,可把这个值叫做函数的[结果](#结果result)。也可以说函数 _结果是_ 某个值。Scala中的每个函数结果都是一个对象。
-* #### 运行时(runtime)
+* ### 运行时(runtime)
正在运行Scala程序的宿主Java虚拟机,或宿主[JVM](#java虚拟机jvm)。运行时这个概念包含了Java虚拟机规范中定义的虚拟机以及Java API和标准Scala API的运行时库。在运行时的这个阶段,意味着程序正在运行中,与编译时是相对的概念。
-* #### 运行时类型(runtime type)
+* ### 运行时类型(runtime type)
对象在运行时的类型。相比之下,[静态类型](#静态类型static-type)指的是表达式在编译时的类型。多数运行时类型都是无类型参数的裸类,比如,`"Hi"`的运行时类型是`String`,`(x: Int) => x + 1`的运行时类型是`Function1`。运行时类型可通过`isInstanceOf`来检测。
-* #### 脚本(script)
+* ### 脚本(script)
包含顶层定义和语句,可直接通过`scala`命令来跑而无需显式编译的文件就是脚本,脚本结尾必须是表达式,而不能是定义。
-* #### 选择器(selector)
+* ### 选择器(selector)
`match`表达式中被匹配的值。比如,在"`s match { case _ => }`"中,选择器是`s`。
-* #### 自身类型(self type)
+* ### 自身类型(self type)
特质的 _自身类型_ 是特质中用到的接收者`this`的假想类型。任何混入特质的具体类必须要确保其类型符合特质的自身类型。自身类型常被用来把大类分解为若干个特质([Programming in Scala](https://www.artima.com/shop/programming_in_scala)第29章有述)。
-* #### 半结构化数据(semi-structured data)
+* ### 半结构化数据(semi-structured data)
XML数据就是半结构化的,因其相比于普通的二进制文件或文本文件更加结构化,而又不像编程语言的数据结构具备完全结构化。
-* #### 序列化(serialization)
+* ### 序列化(serialization)
可把对象 _序列化_ 成字节流,以便将其保存至文件或通过网络传输。之后可对字节流进行 _反序列化_ (可发生在不同计算机上)来获取和原始被序列化的对象一样的对象。
-* #### 遮掩(shadow)
+* ### 遮掩(shadow)
局部变量的重新声明会 _遮掩_ 作用域内相同名称的变量声明。
-* #### 签名(signature)
+* ### 签名(signature)
_签名_ 是[类型签名](#类型签名type-signature)的简写。
-* #### 单例对象(singleton object)
+* ### 单例对象(singleton object)
由object关键字定义的对象。每个单例对象有且仅有一个实例。与某个类共享名称且与这个类定义在同一源文件中的单例对象,叫这个类的[伴生对象](#伴生对象companion-object),类则叫单列对象的[伴生类](#伴生类companion-class)。无伴随类的单例对象叫[独立对象](#独立对象standalone-object)。
-* #### 独立对象(standalone object)
+* ### 独立对象(standalone object)
没有[伴生类](#伴生类companion-class)的[单例对象](#单例对象singleton-object)。
-* #### 语句(statement)
+* ### 语句(statement)
指的是表达式、定义或包导入等这些可放到Scala源码的模板或块中的东西。
-* #### 静态类型(static type)
+* ### 静态类型(static type)
参见[类型](#类型type)。
-* #### 结构类型(structural type)
+* ### 结构类型(structural type)
也是一种[精化类型](#精化类型refinement-type),只是精化的目标是未在基类型中的成员。比如`{ def close(): Unit }`就是结构类型,因其基类型是`AnyRef`,而`AnyRef`并无名为`close`的成员。
-* #### 子类(subclass)
+* ### 子类(subclass)
一个类是其所有[超类](#超类superclass)和[超特质](#超特质supertrait)的 _子类_。
-* #### 子特质(subtrait)
+* ### 子特质(subtrait)
一个特质是其所有[超特质](#超特质supertrait)的 _子特质_。
-* #### 子类型(subtype)
+* ### 子类型(subtype)
Scala编译器允许任何类型在需要该类型的地方使用其 _子类型_ 作为替代。对不带类型参数的类和特质来说,子类型的关系会反映子类的关系。比如,若类`Cat`是抽象类`Animal`的子类,且也不带类型参数,则类型`Cat`就是类型`Animal`的子类型。同样,若特质`Apple`是特质`Fruit`的子特质且无类型参数,则类型`Apple`就是类型`Fruit`的子类型。而对于带有类型参数的类和特质来说,协变就起作用了。比如,由于抽象类`List`被声明为在其长类型参数上是协变的(例,`List`被声明为`List[+A]`),`List[Cat]`是`List[Animal]`的子类型,`List[Apple]`是`List[Fruit]`的子类型。尽管这些类型的类都是`List`,但其子类型的关系依旧是存在的。对比来看,因为`Set`未被声明在其类型参数上是协变的(例,`Set`被声明为`Set[A]`,不带加号),所以`Set[Cat]`并不是`Set[Animal]`的子类型。子类型应该正确实现其超类型的契约,以便应用里氏替换原则(Liskov Substitution Principle),不过编译器仅会在类型检查级别核验此属性。
-* #### 超类(superclass)
+* ### 超类(superclass)
一个类的 _超类_ 包括其直接超类,其直接超类的直接超类,等等一直到`Any`。
-* #### 超特质(supertrait)
+* ### 超特质(supertrait)
类或特质的 _超特质_,如果有的话,就包括所有直接混入类或特质或其任意超类的特质,以及这些特质的所有超特质。
-* #### 超类型(supertype)
+* ### 超类型(supertype)
类型是其所有子类型的 _超类型_。
-* #### 合成类(synthetic class)
+* ### 合成类(synthetic class)
合成类是编译器自动生成的而不是程序员手写的。
-* #### 尾递归(tail recursive)
+* ### 尾递归(tail recursive)
函数是 _尾递归_ 的,仅当函数调用自身的地方是函数的最后一条操作。
-* #### 目标类型化(target typing)
+* ### 目标类型化(target typing)
_目标类型化_ 是参考所需类型来进行类型推导的一种形式。比如在`nums.filter((x) => x > 0)`中,Scala编译器能推导出`x`的类型是`nums`的元素类型,因为`filter`方法会在`nums`的每个元素上调用函数。
-* #### 模板(template)
+* ### 模板(template)
_模板_ 是类、特质或单例对象定义体,它定义了类、特质或对象的类型签名,行为以及初始状态。
-* #### 特质(trait)
+* ### 特质(trait)
_特质_ 通过`trait`关键字定义,是像抽象类一样不带任何值参数,并且可通过被称为[混入组合](#混入组合mixin-composition)的过程"混入到"类或其他特质。当某个特质被混入到其他类或特质,它就被叫做[混入](#混入mixin)。特质可通过一个或多个类型参数化。用类型来参数化后,特质就形成了类型。比如,`Set`是带有单类型参数的特质,而`Set[Int]`却是一个类型。`Set`也被说成是类型`Set[Int]`的"特质"。
-* #### 类型(type)
+* ### 类型(type)
Scala程序中每个变量和表达式都有编译时确定的 _类型_。类型可以在运行时限定变量能指向的值和表达式所能产生的值。如果有必要从对象的[运行时类型](#运行时类型runtime-type)的角度对变量和表达式的类型进行区分的话,他们也被称为 _静态类型_。换句话说,"类型"这个词本身意味着静态类型。类型与类是区分开的因为带有类型参数的类可以构成许多类型。比如,`List`是类不是类型,`List[T]`则是一个带有自由类型参数的类型,`List[Int]`和`List[String]`也是类型(称为实类型因为他们没有自由类型参数)。类型可以有"[类](#类class)"或"[特质](#特质trait)",比如类型`List[Int]`的类是`List`,类型`Set[String]`的特质是`Set`。
-* #### 类型约束(type constraint)
+* ### 类型约束(type constraint)
有些[注解](#注解annotation)是 _类型约束_,意味着他们会对类型能够包含的取值增加额外的限制或约束。比如,`@positive`可以是类型`Int`的类型约束,用来限制32位整型的取值为正的整数。类型约束虽然不会被标准Scala编译器检查,但相应的必须可被额外的工具或编译器插件检查。
-* #### 类型构造器(type constructor)
+* ### 类型构造器(type constructor)
带类型参数的类或特质。
-* #### 类型参数(type parameter)
+* ### 类型参数(type parameter)
必须被填入类型的泛型类或泛型方法的参数。比如,类`List`定义为"`class List[T] { . . . `",对象`Predef`的一个成员方法`identity`定义为"`def identity[T](x:T) = x`",二者定义中的`T`就是类型参数。
-* #### 类型签名(type signature)
+* ### 类型签名(type signature)
方法的 _类型签名_ 包括名称,参数(如果有的话)的数量、顺序和类型,以及结果类型。类、特质或单例对象的类型签名包括名称,所有成员和构造器的类型签名,及其声明的继承和混入关系。
-* #### 统一访问原则(uniform access principle)
+* ### 统一访问原则(uniform access principle)
_统一访问原则_ 指的是变量和无参函数应以相同的语法来访问。Scala通过不允许在无参函数的调用点放置括号来支持该原则。这样的话,无参函数定义就可以改成`val`而不影响客户端代码,_反之亦然_。
-* #### 不可达(unreachable)
+* ### 不可达(unreachable)
在Scala层面,对象可以是 _不可达_ 的,此时其所占据的内存可被运行时回收。不可达并不一定意味着未被引用。引用类型(`AnyRef`的实例)被实现为驻于JVM堆上的对象。当引用类型的实例不可达后,它也确实不被引用了,且可被垃圾回收。值类型(`AnyVal`的实例)可被实现为驻于堆中的基础类型值或Java包装类型实例(如`java.lang.Integer`)。值类型实例可在指向他们的变量的整个生命周期内被装箱(从基础类型值转成包装类型对象)或拆箱(从包装类型对象转成基础类型值)。若表现为JVM堆上的包装类型对象的值类型实例不可达,那就确实不会被引用并且可被垃圾回收。但是若正在表现为基础类型值的值类型不可达,则其仍可被引用,因为此时它并不会以作为对象驻于JVM堆上。运行时可回收不可达对象所占据的内存,但是假如一个Int在运行时被实现为Java基础类型int,在一个运行中的方法的栈帧上占据了一些内存,则这个对象的内存将在方法运行完成且栈帧弹出时才被回收。引用类型的内存,比如`Strings`,可在不可达之后由JVM的垃圾收集器回收。
-* #### 未引用(unreferenced)
+* ### 未引用(unreferenced)
参见[不可达](#不可达unreachable)。
-* #### 值(value)
+* ### 值(value)
Scala中的任何计算或表达式的结果都是一个 _值_,而Scala中的每个值都是一个对象。值这个术语本质上是指对象在内存中(在JVM堆或栈上)的镜像。
-* #### 值类型(value type)
+* ### 值类型(value type)
_值类型_ 是`AnyVal`的任意子类,像`Int`,`Double`或`Unit`。该术语具有Scala源码级别的意味。在运行时,对应于Java基础类型的值类型实例可由基础类型值或包装类型实例来实现,比如`java.lang.Integer`。在值类型实例的整个生命周期内,运行时可将其在基础类型和包装类型间来回转换(如,对其装箱和拆箱)。
-* #### 变量(variable)
+* ### 变量(variable)
指向对象的命名实体。变量要么是`val`,要么是 `var`,`val`变量和`var`变量在定义时都必须被初始化,但仅`var`变量可被重新赋值来指向不同对象。
-* #### 型变(variance)
+* ### 型变(variance)
类或特质的类型参数可用 _型变_ 标号来做标记,即[协变](#协变covariant)(+)或[逆变](#逆变contravariant)(-)。这样的型变标号表明了泛型类或特质的子类化是如何开展的,比如,泛型类`List`在其类型参数上是协变的,因此`List[String]`就是`List[Any]`的子类型。默认情况下,即缺少标号`+`或`-`的类型参数是[非协变](#非协变nonvariant)的。
-* #### 产生(yield)
+* ### 产生(yield)
表达式可以 _产生_ 结果。`yield`关键字指定了[for推解式](#for推解式for-comprehension)的结果。
diff --git a/resources/js/functions.js b/resources/js/functions.js
index d794bf01de..c31e52b22e 100644
--- a/resources/js/functions.js
+++ b/resources/js/functions.js
@@ -427,7 +427,7 @@ $(document).ready(function() {
const DocsPreferences = Storage('org.scala-lang.docs.preferences');
const Scala3 = 'scala-3';
const scalaVersion = DocsPreferences.getPreference('scalaVersion', Scala3);
-
+
function activateTab(tabs, scalaVersion) {
// click the code tab corresponding to the preferred Scala version.
tabs.find('input[data-target=' + scalaVersion + ']').prop("checked", true);
@@ -537,7 +537,7 @@ $('#filter-glossary-terms').focus();
// Loop through the comment list
$(".glossary .toc-context > ul li").each(function(){
// If the name of the glossary term does not contain the text phrase fade it out
- if (jQuery(this).find("h4").text().search(new RegExp(filter, "i")) < 0) {
+ if (jQuery(this).find("h3").text().search(new RegExp(filter, "i")) < 0) {
$(this).fadeOut();
// Show the list item if the phrase matches and increase the count by 1