-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
$span start EXAMPLE | ||
struct S = { | ||
field1 : int, | ||
field2 : string, | ||
} | ||
|
||
function example1(s : S) -> unit = { | ||
// Destructure 's' using let | ||
let struct { field1, _ } = s; | ||
print_int("field1 = ", field1) | ||
} | ||
|
||
// Destructure directly in the function argument | ||
function example2(struct { field1, _ } : S) -> unit = { | ||
print_int("field1 = ", field1) | ||
} | ||
$span end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
/*! | ||
The above block has type `int` and evaluates to the value `6`. | ||
*/ | ||
function example() -> int = { | ||
{ | ||
let x : int = 3; | ||
var y : int = 2; | ||
y = y + 1; | ||
x + y | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
let l : list(int) = 1 :: 2 :: 3 :: [||] | ||
default Order dec | ||
$include <prelude.sail> | ||
|
||
function example1() -> unit = { | ||
let l : list(int) = [|1, 2, 3|] | ||
} | ||
|
||
function example2() -> unit = { | ||
let l : list(int) = 1 :: 2 :: 3 :: [||] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters