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: doc/lang.md
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -348,7 +348,11 @@ Interface assignment copies the pointer, but not the contents of the variable th
348
348
349
349
### Function types
350
350
351
-
A constant that stores an entry point of a function has a function type. A function is characterized by its *signature* that consists of a set of parameter names, types and optional default values, and an optional set of returned value types. The type of the last parameter in the function signature may be prefixed with `..`. The type `..T` is equivalent to `[]T` within the function. Such a function is called *variadic*.
351
+
A constant that stores an entry point of a function has a function type. A function is characterized by its *signature* that consists of a set of parameter names, types and optional default values, and an optional set of returned value types.
352
+
353
+
For a parameter to have a default value, it must be of a comparable type. As a special case, a parameter of type `any` can have the default value `null`.
354
+
355
+
The type of the last parameter in the function signature may be prefixed with `..`. The type `..T` is equivalent to `[]T` within the function. Such a function is called *variadic*.
352
356
353
357
Syntax:
354
358
@@ -362,7 +366,7 @@ Each function definition in the module scope defines a constant of a function ty
362
366
Examples:
363
367
364
368
```
365
-
fn foo(code: int)
369
+
fn foo(code: int = 42)
366
370
fn MyFunc(p: int, x, y: real): (bool, real)
367
371
fn printMsg(msg: char, values: ..real)
368
372
```
@@ -395,9 +399,10 @@ A type to which the comparison operators `==`, `!=`, `<`, `<=`, `>`, `>=` may be
395
399
396
400
* Ordinal types
397
401
* Real types
398
-
* Pointer type
402
+
* Pointer types
399
403
* String type
400
404
* Array types if their item types are comparable
405
+
* Dynamic array types if their item types are comparable
401
406
* Structure types if their field types are comparable
0 commit comments