1
0
Fork 0
forked from fun/fun

Some update in the v0.2 spec.

This commit is contained in:
Johannes Findeisen 2025-09-12 04:40:44 +02:00
commit 96c68b0d27

View file

@ -124,12 +124,14 @@ array<string> names = ["Alice","Bob"]
#### Multidimensional arrays:
```
array<number> matrix = [[1,2],[3,4]]
```
- Arrays or dictionaries can hold different types, even if scalars are strictly typed (including objects later).
```fun
array mixed = [1, "two", true, [3,4]]
array mixed = [1, "two", true, [3,4], matrix]
```
## 4. Variables and Scope
@ -164,26 +166,26 @@ x = "Now I'm a string"
```fun
if(x != y)
print x
print(x)
else if(a == b || h != i)
print a + b
print(a + b)
else
if(k < 1 && l > 1)
print "Buh!"
print("Buh!")
```
### For Loops
```fun
for i in range(1, 10)
print i
print(i)
```
### While Loops
```fun
while x < 10
print x
print(x)
x = x + 1
```
@ -195,7 +197,9 @@ Provided by the runtime (cannot be redefined). Examples:
print, range, system, exec.
```fun
print "Hello, Fun!"
print(a)
number lemmy = range(a, b)
string result = exec("date")
```
### User-Defined Functions
@ -253,12 +257,12 @@ Full path:
```fun
#include math as m
print m.sqrt(16)
print(m.sqrt(16))
```
```fun
#include /home/user/project/universe.fun as u
print u.size()
print(u.size())
```
## 9. Objects
@ -374,14 +378,14 @@ Terminates process.
### Hello World
```fun
print "Hello, World!"
print("Hello, World!")
```
### Loop with Range
```fun
for i in range(1, 5)
print i
print(i)
```
### User Function
@ -390,14 +394,14 @@ for i in range(1, 5)
fun greet(name)
return "Hello " + name
print greet("Fun")
print(greet("Fun"))
```
### System Call
```fun
string now = exec("date")
print "Current time: " + now
print("Current time: " + now)
```
## 15. License