You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Val aims to be:
8
8
-**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.
9
9
-**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.
10
10
-**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.).
11
-
-**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.
11
+
-**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.
12
12
13
13
The [language tour](./pages/language-tour.html) gives an overview of Val's features.
14
14
The [specification](https://github.com/val-lang/specification/blob/main/spec.md) (work in progress) provides detailed information about Val's syntax and semantics.
Copy file name to clipboardExpand all lines: pages/language-tour.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ layout: default
3
3
---
4
4
5
5
This page gives a quick tour of Val's features in the form of a progressive guide.
6
-
It assumes familiarity with an imperative programming language such as JavaScript, Python, C or C++..
6
+
It assumes familiarity with an imperative programming language such as JavaScript, Python, C or C++.
7
7
8
8
This tour does not cover the entire language.
9
9
You may consult the [specification](https://github.com/val-lang/specification/blob/main/spec.md) for more information.
@@ -76,7 +76,7 @@ To run this program:
76
76
77
77
*Alternatively, you may put both source files in a subdirectory, say `Sources/`, and compile the program with `valc Sources -o hello`.*
78
78
79
-
Note that `greet` need not to be `public` to be visible from another file in the module.
79
+
Note that `greet` need not be `public` to be visible from another file in the module.
80
80
All entities declared at the top level of a file are visible everywhere in a module, but not beyond that module's boundary.
81
81
{% comment %}
82
82
Do we need to say, "unless marked private?"
@@ -490,7 +490,7 @@ public fun main() {
490
490
```
491
491
492
492
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`.
493
-
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.
493
+
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.
494
494
495
495
Members that are not declared `public` cannot be accessed outside of the scope of a record type.
496
496
As we uncover more advanced constructs, we will show how to exploit that feature to design clean and safe APIs.
@@ -597,7 +597,7 @@ fun scale(_ v: Vector2, by factor: Vector2) -> Vector2 {
597
597
```
598
598
599
599
Argument labels are also useful to distinguish between different variants of the same operation.
600
-
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.
600
+
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.
601
601
602
602
```val
603
603
typealias Vector2 = (x: Double, y: Double)
@@ -639,7 +639,7 @@ public fun main() {
639
639
}
640
640
```
641
641
642
-
Function can have default values for their parameters:
642
+
Functions can have default values for their parameters:
643
643
644
644
```val
645
645
fun round(_ n: Double, digits: Int = 3) -> Double {
@@ -655,7 +655,7 @@ Hence, one may omit the second argument when calling it.
655
655
656
656
### Parameter passing conventions
657
657
658
-
A parameter passing conventions describes how the value of an argument is passed from caller to callee.
658
+
A parameter passing convention describes how the value of an argument is passed from caller to callee.
659
659
In other words, it describes the semantics of the language at function boundaries.
660
660
661
661
Val provides four different parameter passing conventions: `let`, `inout`, `sink` and `set`.
@@ -685,7 +685,7 @@ So there's a kind of contract between the caller and the callee: both agree not
685
685
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.
686
686
687
687
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.
688
-
In turns, that property guarantees local reasoning and excludes a large class of problems attributed to spooky action at a distance.
688
+
In return, this property guarantees local reasoning and excludes a large class of problems attributed to spooky action at a distance.
689
689
Underneath the user model, the contract also enables a key strategy to efficiently compile pass by value semantics.
690
690
Namely, because the value is guaranteed immutable, the compiler can compile `let` parameters with references.
691
691
@@ -854,7 +854,7 @@ fun offset_sink(_ v: sink Vector2, by delta: Vector2) -> Vector2 {
854
854
Here, the contract says not only that arguments to `sink` parameters are unique, but also that their ownership is transferred to the callee.
855
855
Hence, a caller no can no longer access the value it has given to a `sink` parameter after the callee returns.
856
856
857
-
A C++ developer may understand the `sink` convention as *pass by rvalue reference*, with guarantee that the argument moves, and write the following below.
857
+
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.
858
858
Further, note that a move is a destructive operation in Val.
859
859
860
860
```c++
@@ -971,7 +971,7 @@ public fun main() {
971
971
```
972
972
973
973
The program above declares `Vector2` a [record type](#records) with two public properties, a public memberwise initializer and a method.
974
-
The latter is nearly identical to the free function we declaredin the section on [parameter passing conventions](#parameter-passing-conventions).
974
+
The latter is nearly identical to the free function we declared in the section on [parameter passing conventions](#parameter-passing-conventions).
975
975
The difference is that its first parameter has become implicit and is now named `self`.
976
976
977
977
In a method, `self` denotes the *receiver*, an implicit argument that refers to the value on which the method is called.
@@ -1280,7 +1280,7 @@ public fun main() {
1280
1280
1281
1281
### Subscript bundles
1282
1282
1283
-
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.
1283
+
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.
1284
1284
1285
1285
#### `inout` subscripts
1286
1286
@@ -1316,7 +1316,7 @@ public fun main() {
1316
1316
1317
1317
Here, the immutable variant of the subscript is synthesized from the mutable one.
1318
1318
In some cases, however, you may need to implement different behavior.
1319
-
You such situations, you may bundle multiple implementations together:
1319
+
In such situations, you may bundle multiple implementations together:
0 commit comments