2025-10-25 21:45:08 +11:00
|
|
|
# Funk
|
|
|
|
|
|
|
|
|
|
Funk is an interpreted programming language.
|
|
|
|
|
|
|
|
|
|
## Getting started
|
|
|
|
|
|
|
|
|
|
First of all, you'll need to build the Funk interpreter:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
|
|
|
|
cmake ..
|
|
|
|
|
make
|
|
|
|
|
./funk
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Now you can get coding!
|
|
|
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
|
|
|
|
|
Funk requires a main function for your code to begin execution in. Define it like this:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
println("Hello, World!")
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
You can define other functions and call them if you wish.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
dingus func {
|
|
|
|
|
println("You got dingused")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main func {
|
|
|
|
|
dingus()
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Use `if` and `while` for control flow.
|
|
|
|
|
|
|
|
|
|
Note: Equality operators like `==`, `!=`, etc, etc aren't supported yet. This is a new project, after all.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
if (true) {
|
|
|
|
|
println("It's true!")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
while (true) {
|
|
|
|
|
println("To infinity and beyond!")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Set variables with `=`.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
x = 5
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-10-26 21:12:24 +11:00
|
|
|
And access them by, you know, accessing them.
|
2025-10-25 21:45:08 +11:00
|
|
|
|
2025-10-26 21:12:24 +11:00
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
x = 5
|
|
|
|
|
println(x)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Note: If you'd like you can do this:
|
2025-10-25 21:45:08 +11:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main = func {
|
|
|
|
|
println("Ooh functional looking programming")
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-10-29 11:45:58 +00:00
|
|
|
Or this:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
main func {
|
|
|
|
|
dingus(dingus)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dingus func {
|
|
|
|
|
arg0(arg0)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-10-26 21:12:24 +11:00
|
|
|
<sub>functions are indeed objects >:)</sub>
|
|
|
|
|
|
2025-10-29 11:45:58 +00:00
|
|
|
Funk supports importing other libraries written in Funk (FFI libraries will come soon). Use the import function to import those libraries.
|
|
|
|
|
|
|
|
|
|
Ensure that the library you are importing is in the directory pointed to by the `FUNK_HOME` environment variable.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
// myCoolLibrary.funk
|
|
|
|
|
importedFunction func {
|
|
|
|
|
println("The imported function has been called")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
importedValue = "Hi there from the library!"
|
|
|
|
|
|
|
|
|
|
// main.funk
|
|
|
|
|
import("myCoolLibrary")
|
|
|
|
|
|
|
|
|
|
main func {
|
|
|
|
|
myCoolLibrary::importedFunction()
|
|
|
|
|
println(myCoolLibrary::importedValue)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-10-25 21:45:08 +11:00
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
Funk is licensed to you under the GNU GPL v3.0. Contributions are welcome!
|