Skip to content

Commit

Permalink
Some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpdemarco committed Jul 27, 2022
1 parent 9b8651b commit 56fcc98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Val aims to be:
- **Fast by definition**: Val is compiled ahead-of-time to machine code and relies on its type system to support in-place mutation and avoid unecessary memory allocations. Val avoids hidden costs such as implicit copies and therefore avoids heavy dependence on an optimizer for basic performance.
- **Safe by default**: Val's foundation of [mutable value semantics](http://www.jot.fm/issues/issue_2022_02/article2.pdf) ensures that ordinary code is memory safe, typesafe, and data-race-free. By explicit, auditable opt-in, programmers can use unsafe constructs for performance where necessary, and can build safe constructs using unsafe ones.
- **Simple**: Val borrows heavily from [Swift](https://swift.org) which has demonstrated a user-friendly approach to generic programming and deep support for value semantics. Val's programming model strengthens and extends this support, while de-emphasizing reference semantics and avoiding the complexities that result from trying to make it statically safe (e.g., memory regions, lifetime annotations, etc.).
- **Interoperable with C++**: Programming languages rarely survive in vacuum. Val aims to take advantage of the vast software capital of C++ by supporting full interoperability.
- **Interoperable with C++**: Programming languages rarely survive in a vacuum. Val aims to take advantage of the vast software capital of C++ by supporting full interoperability.

The [language tour](./pages/language-tour.html) gives an overview of Val's features.
The [specification](https://github.com/val-lang/specification/blob/main/spec.md) (work in progress) provides detailed information about Val's syntax and semantics.
Expand Down
26 changes: 13 additions & 13 deletions pages/language-tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: default
---

This page gives a quick tour of Val's features in the form of a progressive guide.
It assumes familiarity with an imperative programming language such as JavaScript, Python, C or C++..
It assumes familiarity with an imperative programming language such as JavaScript, Python, C or C++.

This tour does not cover the entire language.
You may consult the [specification](https://github.com/val-lang/specification/blob/main/spec.md) for more information.
Expand Down Expand Up @@ -76,7 +76,7 @@ To run this program:

*Alternatively, you may put both source files in a subdirectory, say `Sources/`, and compile the program with `valc Sources -o hello`.*

Note that `greet` need not to be `public` to be visible from another file in the module.
Note that `greet` need not be `public` to be visible from another file in the module.
All entities declared at the top level of a file are visible everywhere in a module, but not beyond that module's boundary.
{% comment %}
Do we need to say, "unless marked private?"
Expand Down Expand Up @@ -490,7 +490,7 @@ public fun main() {
```

In the program above, `m.components` can be modified because `m` is a mutable binding **and** the property `components` is mutable, as it is declared with `var`.
Would that property be declared with `let`, the components of the matrix would remain immutable once the matrix has finished initializing, notwistaning the mutability of the binding to which it is assigned.
Would that property be declared with `let`, the components of the matrix would remain immutable once the matrix has finished initializing, notwithstanding the mutability of the binding to which it is assigned.

Members that are not declared `public` cannot be accessed outside of the scope of a record type.
As we uncover more advanced constructs, we will show how to exploit that feature to design clean and safe APIs.
Expand Down Expand Up @@ -597,7 +597,7 @@ fun scale(_ v: Vector2, by factor: Vector2) -> Vector2 {
```

Argument labels are also useful to distinguish between different variants of the same operation.
Further, note that Val does not suppoer type-based overloading, meaning that the only way for two functions to share the same name is to have different argument labels.
Further, note that Val does not support type-based overloading, meaning that the only way for two functions to share the same name is to have different argument labels.

```val
typealias Vector2 = (x: Double, y: Double)
Expand Down Expand Up @@ -639,7 +639,7 @@ public fun main() {
}
```

Function can have default values for their parameters:
Functions can have default values for their parameters:

```val
fun round(_ n: Double, digits: Int = 3) -> Double {
Expand All @@ -655,7 +655,7 @@ Hence, one may omit the second argument when calling it.

### Parameter passing conventions

A parameter passing conventions describes how the value of an argument is passed from caller to callee.
A parameter passing convention describes how the value of an argument is passed from caller to callee.
In other words, it describes the semantics of the language at function boundaries.

Val provides four different parameter passing conventions: `let`, `inout`, `sink` and `set`.
Expand Down Expand Up @@ -685,7 +685,7 @@ So there's a kind of contract between the caller and the callee: both agree not
There's an additional clause in the fine print: the argument is "safe" to use at the entry of the function, meaning that it's fully initialized and that its invariants hold.

An important point to make from the outset is that, for all intents and purposes, this contract states that the value of a `let` parameter is independent from any other value a function might access.
In turns, that property guarantees local reasoning and excludes a large class of problems attributed to spooky action at a distance.
In return, this property guarantees local reasoning and excludes a large class of problems attributed to spooky action at a distance.
Underneath the user model, the contract also enables a key strategy to efficiently compile pass by value semantics.
Namely, because the value is guaranteed immutable, the compiler can compile `let` parameters with references.

Expand Down Expand Up @@ -854,7 +854,7 @@ fun offset_sink(_ v: sink Vector2, by delta: Vector2) -> Vector2 {
Here, the contract says not only that arguments to `sink` parameters are unique, but also that their ownership is transferred to the callee.
Hence, a caller no can no longer access the value it has given to a `sink` parameter after the callee returns.

A C++ developer may understand the `sink` convention as *pass by rvalue reference*, with guarantee that the argument moves, and write the following below.
A C++ developer may understand the `sink` convention as *pass by rvalue reference*, with the guarantee that the argument moves, and write the following below.
Further, note that a move is a destructive operation in Val.

```c++
Expand Down Expand Up @@ -971,7 +971,7 @@ public fun main() {
```

The program above declares `Vector2` a [record type](#records) with two public properties, a public memberwise initializer and a method.
The latter is nearly identical to the free function we declaredin the section on [parameter passing conventions](#parameter-passing-conventions).
The latter is nearly identical to the free function we declared in the section on [parameter passing conventions](#parameter-passing-conventions).
The difference is that its first parameter has become implicit and is now named `self`.

In a method, `self` denotes the *receiver*, an implicit argument that refers to the value on which the method is called.
Expand Down Expand Up @@ -1280,7 +1280,7 @@ public fun main() {

### Subscript bundles

Just like methods, subscripts and member subscripts can bindle multiple implementations to represent different variant of the same functionality depending on the context in which the subscript is being used.
Just like methods, subscripts and member subscripts can bundle multiple implementations to represent different variant of the same functionality depending on the context in which the subscript is being used.

#### `inout` subscripts

Expand Down Expand Up @@ -1316,7 +1316,7 @@ public fun main() {

Here, the immutable variant of the subscript is synthesized from the mutable one.
In some cases, however, you may need to implement different behavior.
You such situations, you may bundle multiple implementations together:
In such situations, you may bundle multiple implementations together:

```
subscript min(_ x: yielded Int, _ y: yielded Int): Int {
Expand All @@ -1328,7 +1328,7 @@ subscript min(_ x: yielded Int, _ y: yielded Int): Int {
#### `set` subscripts

A `set` subscript does not project any value.
Instead, it used when the value produced by a subscript needs not to be used, but only assigned to a new value.
Instead, it is used when the value produced by a subscript need not be used, but only assigned to a new value.

A `set` subscript accepts an implicit `sink` parameter named `new_value` denoting the value to assign:

Expand All @@ -1346,7 +1346,7 @@ public fun main() {
```

In the program above, the value of the subscript is not required to perform the assigment.
So rather than applying the `inout` variant, the compiler will choses to apply the `set` variant.
So rather than applying the `inout` variant, the compiler will choose to apply the `set` variant.

#### `sink` subscripts

Expand Down

0 comments on commit 56fcc98

Please sign in to comment.