Some update in the v0.1 spec.
This commit is contained in:
parent
be5fa017ba
commit
39a48d5ddf
2 changed files with 47 additions and 15 deletions
|
|
@ -150,7 +150,7 @@ cast(a)
|
||||||
return CASTED_variable_from_one_to_another_existing_type(a)
|
return CASTED_variable_from_one_to_another_existing_type(a)
|
||||||
|
|
||||||
// External functions need f as a prefix to define the function.
|
// 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
|
return a_string + " " + b_string
|
||||||
eof
|
eof
|
||||||
|
|
||||||
|
|
|
||||||
60
spec/v0.1.md
60
spec/v0.1.md
|
|
@ -95,7 +95,7 @@ boolean flag = true
|
||||||
|
|
||||||
```fun
|
```fun
|
||||||
byte b1 = 0x23
|
byte b1 = 0x23
|
||||||
byte b2 = "A"
|
byte b2 = 'A'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Array
|
### Array
|
||||||
|
|
@ -119,10 +119,10 @@ private number count = 42
|
||||||
|
|
||||||
## 5. Operators
|
## 5. Operators
|
||||||
|
|
||||||
- Arithmetic: + - * / %
|
- Arithmetic: `+`, `-`, `*`, `/`, `%`
|
||||||
- Comparison: == != > < >= <=
|
- Comparison: `==`, `!=`, `>`, `<`, `>=`, `<=`
|
||||||
- Boolean: && || !
|
- Boolean: `&&`, `||`, `!`
|
||||||
- Assignment: =
|
- Assignment: `=`
|
||||||
|
|
||||||
## 6. Control Flow
|
## 6. Control Flow
|
||||||
|
|
||||||
|
|
@ -136,8 +136,6 @@ else if(a == b || h != i)
|
||||||
else
|
else
|
||||||
if(k < 1 && l > 1)
|
if(k < 1 && l > 1)
|
||||||
print "Buh!"
|
print "Buh!"
|
||||||
fi
|
|
||||||
fi
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### For Loops
|
### For Loops
|
||||||
|
|
@ -168,10 +166,10 @@ print "Hello, Fun!"
|
||||||
|
|
||||||
### User-Defined Functions
|
### User-Defined Functions
|
||||||
|
|
||||||
Must be declared with the f prefix.
|
Must be declared with the fun prefix.
|
||||||
|
|
||||||
```fun
|
```fun
|
||||||
f add(a, b)
|
fun add(a, b)
|
||||||
return a + b
|
return a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -205,12 +203,14 @@ From the current working directory:
|
||||||
Full path:
|
Full path:
|
||||||
|
|
||||||
```fun
|
```fun
|
||||||
#include /home/user/project/lib.fun
|
#include /home/user/project/lib.fun
|
||||||
```
|
```
|
||||||
|
|
||||||
## 9. System Integration
|
## 9. System Integration
|
||||||
|
|
||||||
### system
|
### Blocking
|
||||||
|
|
||||||
|
#### system(cmd)
|
||||||
|
|
||||||
Executes a command, returns exit code.
|
Executes a command, returns exit code.
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ Executes a command, returns exit code.
|
||||||
system("ls -l")
|
system("ls -l")
|
||||||
```
|
```
|
||||||
|
|
||||||
### exec
|
#### exec(cmd)
|
||||||
|
|
||||||
Executes a command, returns stdout.
|
Executes a command, returns stdout.
|
||||||
|
|
||||||
|
|
@ -226,14 +226,46 @@ Executes a command, returns stdout.
|
||||||
string result = exec("date")
|
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.
|
Executes a command asynchronously, returns process ID.
|
||||||
|
|
||||||
```fun
|
```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
|
## 10. Error Handling
|
||||||
|
|
||||||
- No implicit type coercion.
|
- No implicit type coercion.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue