-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffects.affine
More file actions
35 lines (28 loc) · 1.15 KB
/
Copy patheffects.affine
File metadata and controls
35 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: PMPL-1.0-or-later
// AffineScript Standard Library - Effect Declarations
// Core IO effect - file and console operations
effect IO;
// State effect - mutable references
effect Mut;
// Exception effect - panics and error handling
effect Throws;
// Built-in IO operations
extern fn print(s: String) -> Unit / IO;
extern fn println(s: String) -> Unit / IO;
extern fn read_line() -> String / IO;
extern fn read_file(path: String) -> String / IO;
extern fn write_file(path: String, content: String) -> Unit / IO;
// Built-in State operations
// `make_ref` (not `ref`) because `ref` is a reserved ownership keyword;
// see #135 keyword-as-identifier slice.
extern fn make_ref<T>(x: T) -> Ref<T> / Mut;
extern fn get<T>(r: Ref<T>) -> T / Mut;
extern fn set<T>(r: Ref<T>, x: T) -> Unit / Mut;
// Built-in Exception operations
extern fn panic(msg: String) -> Never / Throws;
extern fn error<T>(msg: String) -> T / Throws;
// Pure operations (no effects)
extern fn int_to_string(n: Int) -> String;
extern fn string_to_int(s: String) -> Option<Int>;
extern fn string_length(s: String) -> Int;
extern fn string_concat(s1: String, s2: String) -> String;