1
0
Fork 0
forked from fun/fun

Some update in the v0.1 spec.

This commit is contained in:
Johannes Findeisen 2025-09-12 00:01:25 +02:00
commit 39a48d5ddf
2 changed files with 47 additions and 15 deletions

View file

@ -150,7 +150,7 @@ cast(a)
return CASTED_variable_from_one_to_another_existing_type(a)
// External functions need f as a prefix to define the function.
f get_string(a_string, b_string)
fun get_string(a_string, b_string)
return a_string + " " + b_string
eof

View file

@ -95,7 +95,7 @@ boolean flag = true
```fun
byte b1 = 0x23
byte b2 = "A"
byte b2 = 'A'
```
### Array
@ -119,10 +119,10 @@ private number count = 42
## 5. Operators
- Arithmetic: + - * / %
- Comparison: == != > < >= <=
- Boolean: && || !
- Assignment: =
- Arithmetic: `+`, `-`, `*`, `/`, `%`
- Comparison: `==`, `!=`, `>`, `<`, `>=`, `<=`
- Boolean: `&&`, `||`, `!`
- Assignment: `=`
## 6. Control Flow
@ -136,8 +136,6 @@ else if(a == b || h != i)
else
if(k < 1 && l > 1)
print "Buh!"
fi
fi
```
### For Loops
@ -168,10 +166,10 @@ print "Hello, Fun!"
### User-Defined Functions
Must be declared with the f prefix.
Must be declared with the fun prefix.
```fun
f add(a, b)
fun add(a, b)
return a + b
```
@ -205,12 +203,14 @@ From the current working directory:
Full path:
```fun
&#35;include /home/user/project/lib.fun
#include /home/user/project/lib.fun
```
## 9. System Integration
### system
### Blocking
#### system(cmd)
Executes a command, returns exit code.
@ -218,7 +218,7 @@ Executes a command, returns exit code.
system("ls -l")
```
### exec
#### exec(cmd)
Executes a command, returns stdout.
@ -226,14 +226,46 @@ Executes a command, returns stdout.
string result = exec("date")
```
### spawn
### Non-Blocking
#### nsystem(cmd)
Executes a command, returns exit code.
```fun
system("ls -l")
```
#### nexec(cmd)
Executes a command, returns stdout.
```fun
string result = exec("date")
```
#### nspawn(cmd)
Executes a command asynchronously, returns process ID.
```fun
number pid = spawn("sleep 10")
number pid = nspawn("sleep 10")
```
### Helpers
#### wait(pid)
Blocks until process finishes, returns exit code.
#### read(pid)
Returns captured stdout (for processes started with nexec).
#### kill(pid)
Terminates process.
## 10. Error Handling
- No implicit type coercion.