From 39a48d5ddf80d08dd7c98ae965e0b54872f015b3 Mon Sep 17 00:00:00 2001 From: hanez Date: Fri, 12 Sep 2025 00:01:25 +0200 Subject: [PATCH] Some update in the v0.1 spec. --- draft.fun | 2 +- spec/v0.1.md | 60 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/draft.fun b/draft.fun index ca5478e..eebf310 100644 --- a/draft.fun +++ b/draft.fun @@ -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 diff --git a/spec/v0.1.md b/spec/v0.1.md index 7b49d44..bb10f16 100644 --- a/spec/v0.1.md +++ b/spec/v0.1.md @@ -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 -#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.