From f1c75b74257e3fcfea39365d41072133af5a13ac Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 16 Mar 2019 19:42:59 -0700 Subject: [PATCH 1/2] Add some terms to the glossary. --- src/glossary.md | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/glossary.md b/src/glossary.md index defa63f82..c9f988649 100644 --- a/src/glossary.md +++ b/src/glossary.md @@ -1,6 +1,6 @@ # Glossary -### Abstract Syntax Tree +### Abstract syntax tree An ‘abstract syntax tree’, or ‘AST’, is an intermediate representation of the structure of the program when the compiler is compiling it. @@ -23,7 +23,7 @@ An array, sometimes also called a fixed-size array or an inline array, is a valu describing a collection of elements, each selected by an index that can be computed at run time by the program. It occupies a contiguous region of memory. -### Associated Item +### Associated item An associated item is an item that is associated with another item. Associated items are defined in [implementations] and declared in [traits]. Only functions, @@ -48,7 +48,7 @@ run when it involves polymorphism. Two major forms of dispatch are static dispat dynamic dispatch. While Rust favors static dispatch, it also supports dynamic dispatch through a mechanism called ‘trait objects’. -### Dynamically Sized Type +### Dynamically sized type A dynamically sized type (DST) is a type without a statically known size or alignment. @@ -59,18 +59,32 @@ and functions that evaluate to a single value, with or without side-effects. For example, `2 + (3 * 4)` is an expression that returns the value 14. +### Free function + +A [function] that is not a member of an [implementation]. + +### Inherent implementation + +An [implementation] that applies to a nominal type, not to a trait. +[More][inherent implementation]. + +### Inherent method + +A [method] defined in an [inherent implementation], not in a trait +implementation. + ### Initialized A variable is initialized if it has been assigned a value and hasn't since been -moved from. All other memory locations are assumed to be initialized. Only +moved from. All other memory locations are assumed to be uninitialized. Only unsafe Rust can create such a memory without initializing it. -### Nominal Types +### Nominal types Types that can be referred to by a path directly. Specifically [enums], [structs], [unions], and [trait objects]. -### Object Safe Traits +### Object safe traits [Traits] that can be used as [trait objects]. Only traits that follow specific [rules][object safety] are object safe. @@ -136,11 +150,22 @@ It allows a type to make certain promises about its behavior. Generic functions and generic structs can use traits to constrain, or bound, the types they accept. +### Undefined behavior + +Compile-time or run-time behavior that is not specified. This may result in, +but is not limited to: process termination or corruption; improper, incorrect, +or unintended computation; or platform-specific results. +[More][undefined-behavior]. + [alignment]: type-layout.html#size-and-alignment [enums]: items/enumerations.html +[function]: items/functions.html +[implementation]: items/implementations.html +[implementations]: items/implementations.html +[inherent implementation]: items/implementations.html#inherent-implementations +[method]: items/associated-items.html#methods +[object safety]: items/traits.html#object-safety [structs]: items/structs.html -[unions]: items/unions.html [trait objects]: types/trait-object.html -[implementations]: items/implementations.html [traits]: items/traits.html -[object safety]: items/traits.html#object-safety +[unions]: items/unions.html From 8fe1f8210bb3399ee2913625977dbb55e4f91a71 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 19 Mar 2019 10:06:58 -0700 Subject: [PATCH 2/2] Update for review comments. --- src/glossary.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/glossary.md b/src/glossary.md index c9f988649..1864ff4b4 100644 --- a/src/glossary.md +++ b/src/glossary.md @@ -26,8 +26,9 @@ at run time by the program. It occupies a contiguous region of memory. ### Associated item An associated item is an item that is associated with another item. Associated -items are defined in [implementations] and declared in [traits]. Only functions, -constants, and type aliases can be associated. +items are defined in [implementations] and declared in [traits]. Only +functions, constants, and type aliases can be associated. Contrast to a [free +item]. ### Bound @@ -59,13 +60,14 @@ and functions that evaluate to a single value, with or without side-effects. For example, `2 + (3 * 4)` is an expression that returns the value 14. -### Free function +### Free item -A [function] that is not a member of an [implementation]. +An [item] that is not a member of an [implementation], such as a *free +function* or a *free const*. Contrast to an [associated item]. ### Inherent implementation -An [implementation] that applies to a nominal type, not to a trait. +An [implementation] that applies to a nominal type, not to a trait-type pair. [More][inherent implementation]. ### Inherent method @@ -158,11 +160,14 @@ or unintended computation; or platform-specific results. [More][undefined-behavior]. [alignment]: type-layout.html#size-and-alignment +[associated item]: #associated-item [enums]: items/enumerations.html +[free item]: #free-item [function]: items/functions.html [implementation]: items/implementations.html [implementations]: items/implementations.html [inherent implementation]: items/implementations.html#inherent-implementations +[item]: items.html [method]: items/associated-items.html#methods [object safety]: items/traits.html#object-safety [structs]: items/structs.html