Skip to content

Fix typo #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/01_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Another important decision is the static typing with type inference, which will

## An incremental language

The HULK language really is a set of closely related programming languages. What we will call basic HULK consists of a minimum subset that is extended by a set of additional features. The basic language contains expressions, global functions and a unified type system with simple inheritance. The extensions include support for arrays, delegates, type inference, iterators, among other characteristics. These extensions have been designed to be compatible with the rest of HULK, including the other the extensions. It should be possible, once a basic compiler is implemented, to add any subset of these extensions without breaking previous code.
The HULK language really is a set of closely related programming languages. What we will call basic HULK consists of a minimum subset that is extended by a set of additional features. The basic language contains expressions, global functions and a unified type system with simple inheritance. The extensions include support for arrays, delegates, type inference, iterators, among other characteristics. These extensions have been designed to be compatible with the rest of HULK, including the other extensions. It should be possible, once a basic compiler is implemented, to add any subset of these extensions without breaking previous code.

This design has been conceived to allow the use of HULK in a wide range of learning levels. As a language of expressions and functions, it is useful for introductory courses on parsing and basic compilation techniques. Object orientation introduces a whole universe of semantic complexities; however, the HULK type system is simple enough to illustrate the most common problems in semantic type verification. On the other hand, each one of the extensions introduces advanced and interesting problems. Arrays introduce problems related to memory management, while anonymous functions and iterators are fundamentally problems of transpilation and code generation. The inference of types and the verification of null-safety is an exercise in logical inference, which can be used in advanced courses. The idea is that each course defines its objectives of interest, and can use an appropriate subset of HULK to illustrate and evaluate them.

## BANNER: Intermediate Representation

Even though HULK can be defined without specific compilation details, we also provide a didactic 3-address code for intermediate representation that is convenient to use with HULK. For obvious reasons, it's called BANNER -- **B**asic 3-**A**dress li**N**ear i**N**t**E**mediate **R**epresentation.
Even though HULK can be defined without specific compilation details, we also provide a didactic 3-address code for intermediate representation that is convenient to use with HULK. For obvious reasons, it's called BANNER -- **B**asic 3-**A**ddress li**N**ear i**N**t**E**rmediate **R**epresentation.
2 changes: 1 addition & 1 deletion docs/02_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The rest of this section explains the basic expressions in HULK.
HULK defines three types of literal values: **numbers**, **strings**, and **booleans**.
We will leave strings and booleans for later.

Numbers are 32-bit floating-point and support all basic arithmetic operations with the usual semantics: `+` (addition), `-` (subtraction), `*` (multiplication), `\` (floating-point division), `^` (power), and parenthesized sub-expressions.
Numbers are 32-bit floating-point and support all basic arithmetic operations with the usual semantics: `+` (addition), `-` (subtraction), `*` (multiplication), `/` (floating-point division), `^` (power), and parenthesized sub-expressions.

The following is a valid HULK program that computes and prints the result of a rather useless arithmetic expression:

Expand Down
2 changes: 1 addition & 1 deletion docs/04_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ let a = 0 in
};
```

This is useful if you want to evaluate a complex expression to both test it (e.g, to se if its not null) and store it for later use.
This is useful if you want to evaluate a complex expression to both test it (e.g, to see if its not null) and store it for later use.
2 changes: 1 addition & 1 deletion docs/05_conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let a = 42 in
The `if` expression supports multiple branches with the `elseif` construction, which introduces another conditioned branch:

```js
let a = 42, let mod = a % 3 in
let a = 42, mod = a % 3 in
print(
if (mod == 0) "Magic"
elseif (mod % 3 == 1) "Woke"
Expand Down
2 changes: 1 addition & 1 deletion docs/06_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permalink: /loops
# Loops

HULK defines two kinds of loops, the `while` expression and the `for` expression.
Both loop constructions are expressions, returing the value of the
Both loop constructions are expressions, returning the value of the last body expression.

## The `while` loop

Expand Down
4 changes: 2 additions & 2 deletions docs/07_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ permalink: /types

# Types

HULK is ultimately an object-oriented language with simple inheritance and nominal typing. It also has features of structural typing via [protocols](/protocols), which support language features such as [iteratbles](/iteratbles), which we will explain later.
HULK is ultimately an object-oriented language with simple inheritance and nominal typing. It also has features of structural typing via [protocols](/protocols), which support language features such as [iterables](/iterables), which we will explain later.

This section explains the basics of HULK's nominal typing system.

A type in HULK is basically a collection of attributes and methods, encapsulated under a type name. Attributes are always private, which means they can't be read or writen to from any code outside the type in which they are defined (not even inheritors), while methods are always public and virtual.
A type in HULK is basically a collection of attributes and methods, encapsulated under a type name. Attributes are always private, which means they can't be read or written to from any code outside the type in which they are defined (not even inheritors), while methods are always public and virtual.

## Declaring types

Expand Down
4 changes: 2 additions & 2 deletions docs/08_typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permalink: /typing

HULK is a statically-typed language with optional type annotations. So far you haven't seen any because HULK has a powerful [type inference system](/inference) which we will talk about later on. However, all symbols in HULK have a static type, and all programs in HULK are statically checked during compilation.

Tye annotations can be added anywhere a symbol is defined, that is:
Type annotations can be added anywhere a symbol is defined, that is:

- in variable declarations with `let` expressions;
- in function or method arguments and return type;
Expand Down Expand Up @@ -59,7 +59,7 @@ The type checker will verify that type arguments are used consistently inside at

## Type conforming

The basic type relation in HULK is called *conforming* (`<=`). A type `T1` is said to *conform to* to another type `T2` (writen as `T1 <= T2`) if a variable of type `T2` can hold a value of type `T1` such that every possible operation that is semantically valid with `T2` is guaranteed to be semantically valid with `T1`.
The basic type relation in HULK is called *conforming* (`<=`). A type `T1` is said to *conform to* another type `T2` (writen as `T1 <= T2`) if a variable of type `T2` can hold a value of type `T1` such that every possible operation that is semantically valid with `T2` is guaranteed to be semantically valid with `T1`.

In general, this means that the type checker will verify that the inferred type for any expression conforms to the corresponding type declared for that expression (e.g., the type of a variable, or the return type of a function).

Expand Down
2 changes: 1 addition & 1 deletion docs/09_inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Hence, there are two different moments when a semantic error can be reported. Fi

## Type inference of expressions

The first task of the type inferer is to infer the runtime type of any expression that appears in a HULK program. This process is performed bottom-up, starting from atomic sub-expressions (e.g., literals) and working up the AST. The exact rules for type inference of expressions is given in the section a`bout [type semantics](/type_semantics), but an intuitive introduction can be given at this point.
The first task of the type inferer is to infer the runtime type of any expression that appears in a HULK program. This process is performed bottom-up, starting from atomic sub-expressions (e.g., literals) and working up the AST. The exact rules for type inference of expressions is given in the section about [type semantics](/type_semantics), but an intuitive introduction can be given at this point.

Literals are the easiest to type-infer, because their type comes directly from the parser. Arithmetic expressions are also easy, because their type is always `Number`. Likewise, string and boolean operators are straightforward.

Expand Down
2 changes: 1 addition & 1 deletion docs/10_protocols.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Person {
let x : Hashable = new Person() in print(x.hash());
```

Anywhere you can annotate a symbol with a type (variables, attributes, function,method and type arguments, and return values), you can also use a protocol. For the purpose of type inference, protocols are treated as types.
Anywhere you can annotate a symbol with a type (variables, attributes, function, method and type arguments, and return values), you can also use a protocol. For the purpose of type inference, protocols are treated as types.

## Covariance and contravariance in protocol implementation

Expand Down
6 changes: 3 additions & 3 deletions docs/12_vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let numbers = [1,2,3,4,5,6,7,8,9] in
print(x);
```

Because vectors implement the iterable protocol, you can explicitely find a `next` and `current` methods in case you ever need them. Besides that, vectors also have a `size(): Number` method that returns the number of items in the vector.
Because vectors implement the iterable protocol, you can explicitly find a `next` and `current` methods in case you ever need them. Besides that, vectors also have a `size(): Number` method that returns the number of items in the vector.

Vectors also support an indexing syntax using square brackets `[]`, as in the following example:

Expand All @@ -31,11 +31,11 @@ let numbers = [1,2,3,4,5,6,7,8,9] in print(numbers[7]);

## Implicit syntax

An implicit vector can be created using what we call a generator pattern, which is always an expression Here's an example:
An implicit vector can be created using what we call a generator pattern, which is always an expression. Here's an example:

```js
let squares = [x^2 | x in range(1,10)] in print(x);
// prints 2, 4, 6, 8, 10, ...
// prints 1, 4, 9, 16, 25, ...
```

## Typing vectors
Expand Down