2015-02-15 12:37:49 -06:00
|
|
|
|
% Glossary
|
|
|
|
|
|
2015-02-15 13:41:44 -06:00
|
|
|
|
Not every Rustacean has a background in systems programming, nor in computer
|
|
|
|
|
science, so we've added explanations of terms that might be unfamiliar.
|
2015-02-15 12:37:49 -06:00
|
|
|
|
|
2015-03-19 18:42:35 -05:00
|
|
|
|
### Abstract Syntax Tree
|
|
|
|
|
|
2015-07-23 06:24:55 -05:00
|
|
|
|
When a compiler is compiling your program, it does a number of different things.
|
|
|
|
|
One of the things that it does is turn the text of your program into an
|
|
|
|
|
‘abstract syntax tree’, or ‘AST’. This tree is a representation of the structure
|
|
|
|
|
of your program. For example, `2 + 3` can be turned into a tree:
|
2015-03-19 18:42:35 -05:00
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
+
|
|
|
|
|
/ \
|
|
|
|
|
2 3
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
And `2 + (3 * 4)` would look like this:
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
+
|
|
|
|
|
/ \
|
|
|
|
|
2 *
|
|
|
|
|
/ \
|
|
|
|
|
3 4
|
|
|
|
|
```
|
2015-07-23 06:24:55 -05:00
|
|
|
|
|
|
|
|
|
### Arity
|
|
|
|
|
|
|
|
|
|
Arity refers to the number of arguments a function or operation takes.
|
|
|
|
|
|
|
|
|
|
```rust
|
|
|
|
|
let x = (2, 3);
|
|
|
|
|
let y = (4, 6);
|
|
|
|
|
let z = (8, 2, 6);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
In the example above `x` and `y` have arity 2. `z` has arity 3.
|
|
|
|
|
|
2015-10-22 23:45:44 -05:00
|
|
|
|
### Bounds
|
|
|
|
|
|
|
|
|
|
Bounds are constraints on a type or [trait][traits]. For example, if a bound
|
|
|
|
|
is placed on the argument a function takes, types passed to that function
|
|
|
|
|
must abide by that constraint.
|
|
|
|
|
|
|
|
|
|
[traits]: traits.html
|
|
|
|
|
|
2015-08-20 15:05:39 -05:00
|
|
|
|
### DST (Dynamically Sized Type)
|
|
|
|
|
|
|
|
|
|
A type without a statically known size or alignment. ([more info][link])
|
|
|
|
|
|
2015-10-05 11:25:54 -05:00
|
|
|
|
[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts
|
2015-08-20 15:05:39 -05:00
|
|
|
|
|
2015-07-23 06:24:55 -05:00
|
|
|
|
### Expression
|
|
|
|
|
|
|
|
|
|
In computer programming, an expression is a combination of values, constants,
|
|
|
|
|
variables, operators and functions that evaluate to a single value. For example,
|
|
|
|
|
`2 + (3 * 4)` is an expression that returns the value 14. It is worth noting
|
|
|
|
|
that expressions can have side-effects. For example, a function included in an
|
|
|
|
|
expression might perform actions other than simply returning a value.
|
|
|
|
|
|
|
|
|
|
### Expression-Oriented Language
|
|
|
|
|
|
2015-07-25 04:42:46 -05:00
|
|
|
|
In early programming languages, [expressions][expression] and
|
2015-07-24 06:12:11 -05:00
|
|
|
|
[statements][statement] were two separate syntactic categories: expressions had
|
|
|
|
|
a value and statements did things. However, later languages blurred this
|
|
|
|
|
distinction, allowing expressions to do things and statements to have a value.
|
|
|
|
|
In an expression-oriented language, (nearly) every statement is an expression
|
2015-07-25 04:42:46 -05:00
|
|
|
|
and therefore returns a value. Consequently, these expression statements can
|
2015-07-24 06:12:11 -05:00
|
|
|
|
themselves form part of larger expressions.
|
|
|
|
|
|
|
|
|
|
[expression]: glossary.html#expression
|
|
|
|
|
[statement]: glossary.html#statement
|
2015-07-23 06:24:55 -05:00
|
|
|
|
|
|
|
|
|
### Statement
|
|
|
|
|
|
|
|
|
|
In computer programming, a statement is the smallest standalone element of a
|
|
|
|
|
programming language that commands a computer to perform an action.
|