1
0
Fork 0
forked from fun/fun

Moved all docs from ./docs/ to ./web/documentation/ to be available on the website. No code changes. (0.40.5)

This commit is contained in:
Johannes Findeisen 2026-04-10 23:27:55 +02:00
commit 567fa73796
224 changed files with 4584 additions and 1139 deletions

View file

@ -148,8 +148,8 @@ If you're curious about Fun, check out:
- [Website](https://fun-lang.xyz)
- [Git Repository](https://git.xw3.org/fun/fun){:class="git"}
- [Fun Handbook](https://git.xw3.org/fun/fun/src/branch/main/docs/handbook.md){:class="git"}
- [Fun REPL Guide](https://git.xw3.org/fun/fun/src/branch/main/docs/repl.md){:class="git"}
- [Fun Handbook](https://fun-lang.xyz/documentation/handbook/){:class="git"}
- [Fun REPL Guide](https://fun-lang.xyz/documentation/repl/){:class="git"}
- [Specification v0.3](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.3.md){:class="git"}
- [Examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}
- [Standard Library](https://git.xw3.org/fun/fun/src/branch/main/lib){:class="git"}
@ -159,9 +159,9 @@ The examples directory contains demonstrations of most Fun features, from basic
### For Developers
- [Fun Internals](https://git.xw3.org/fun/fun/src/branch/main/docs/internals.md){:class="git"}
- [Fun Opcodes](https://git.xw3.org/fun/fun/src/branch/main/docs/opcodes.md){:class="git"}
- [Basic Rust Opcodes Support](https://git.xw3.org/fun/fun/src/branch/main/docs/rust.md){:class="git"}
- [Fun Internals](https://fun-lang.xyz/documentation/internals/){:class="git"}
- [Fun Opcodes](https://fun-lang.xyz/documentation/opcodes/){:class="git"}
- [Basic Rust Opcodes Support](https://fun-lang.xyz/documentation/rust/){:class="git"}
### The Road Ahead

223
web/documentation/arrays.md Normal file
View file

@ -0,0 +1,223 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Arrays in Fun
subtitle: Working with arrays, creation, indexing/slicing, iteration patterns, helpers, and idioms.
description: Working with arrays, creation, indexing/slicing, iteration patterns, helpers, and idioms.
permalink: /documentation/arrays/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Arrays in Fun
This guide focuses on arrays: creation, indexing, mutation, iteration, slicing, and common gotchas. It complements the quick overview in types.md with a deeper, exampledriven treatment.
## What is an array?
- Ordered, zeroindexed, mutable sequence of values.
- Can hold mixed types (numbers, strings, maps, arrays, …) in the same array.
- Boundschecked indexing; outofrange access is a runtime error.
## Creating arrays
```
// literals
a = [1, 2, 3]
b = ["alpha", "beta"]
empty = []
// nested
grid = [[1,2], [3,4]]
print(typeof(a)) // "array"
print(len(a)) // 3
```
Tip: Prefer squarebracket literals for clarity and performance versus building via repeated push in a hot loop.
## Indexing (0based) and assignment
```
a = [10, 20, 30]
print(a[0]) // 10
print(a[2]) // 30
// update in place
a[1] = 42
print(a) // [10, 42, 30]
```
Notes:
- Valid indices are 0..len(a)-1. Using an invalid index raises a runtime error.
- Assignment updates the existing array; references pointing to it observe the change.
## Appending, popping, inserting, removing
```
a = [1]
// append to end; returns new length
push(a, 7) // => 2, a is now [1, 7]
// pop last element; returns the removed value
v = apop(a) // v = 7, a is now [1]
// insert at index (shifts elements to the right)
a = [1, 2, 3]
insert(a, 1, 99) // a => [1, 99, 2, 3]
// remove at index (shifts left)
remove(a, 2) // a => [1, 99, 3]
```
## Slicing and concatenation
```
a = [0,1,2,3,4]
// slice(startInclusive, endExclusive)
head = slice(a, 0, 3) // [0,1,2]
mid = slice(a, 1, 4) // [1,2,3]
// concat: join two arrays
b = ["x", "y"]
ab = concat(a, b) // [0,1,2,3,4,"x","y"]
```
Slicing returns a new array. The original is unchanged.
## Iteration patterns
```
a = ["a", "b", "c"]
// indexbased loop
for i = 0; i < len(a); i = i + 1 {
print(a[i])
}
// enumerate helper (if available in your stdlib setup)
#include <utils/iter.fun> as it
for pair in it.enumerate(a) {
idx = pair[0]
val = pair[1]
print(to_string(idx) + ":" + val)
}
```
## Copying vs. referencing
Arrays are reference types. Assigning just copies the reference, not the contents:
```
orig = [1, 2]
alias = orig // points to the same array
alias[0] = 9
print(orig) // [9, 2]
// create a shallow copy via slice
copy = slice(orig, 0, len(orig))
copy[1] = 7
print(orig) // [9, 2]
print(copy) // [9, 7]
```
Shallow copies duplicate the toplevel array but not nested structures.
## Equality
```
print([1,2] == [1,2]) // true
print([1,2] == [2,1]) // false
```
Array equality compares length and elementwise equality recursively.
## Common utilities
Depending on your build/stdlib configuration, these helpers may be available:
- len(a): number of elements
- push(a, v), apop(a)
- insert(a, idx, v), remove(a, idx)
- slice(a, start, end)
- concat(a, b)
- find(a, v): index or -1
- contains(a, v): 1 or 0
Check your lib directory (e.g., lib/utils) for additional helpers.
## Error handling and bounds
```
a = [0]
// a[1] is out of range → runtime error
```
Tips:
- Guard indices: if i < 0 or i >= len(a) { /* handle */ }
- Use remove/insert carefully inside loops; indices of following items change.
## Interop with maps and strings
```
// arrays of maps
users = [ {"name":"Ada"}, {"name":"Lin"} ]
print(users[1]["name"]) // Lin
// split/join patterns depend on your stdlib
#include <utils/strings.fun> as su // adjust if present in your tree
parts = su.split("a,b,c", ",") // ["a","b","c"]
csv = su.join(parts, ",") // "a,b,c"
```
## Performance tips
- Preallocate by building from literals or chunked appends rather than onebyone in very tight loops.
- Prefer index loops over repeated remove/insert in the middle of large arrays.
- Use slice to copy only when necessary; keep references for readonly sharing.
## Examples
```
// filter even numbers
src = [0,1,2,3,4,5]
dst = []
for i = 0; i < len(src); i = i + 1 {
v = src[i]
if v % 2 == 0 { push(dst, v) }
}
print(dst) // [0,2,4]
// flatten one level
nested = [[1,2], [3], [], [4,5]]
flat = []
for i = 0; i < len(nested); i = i + 1 {
row = nested[i]
for j = 0; j < len(row); j = j + 1 {
push(flat, row[j])
}
}
print(flat) // [1,2,3,4,5]
```
## See also
- types.md — broader overview of core types with quick array examples.
- examples/ — many scripts operate on arrays; try play.fun to explore.

View file

@ -0,0 +1,236 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Async I/O ("asyncio") in Fun
subtitle: Async I/O primitives and patterns, non-blocking sockets, fd polling, examples, and best practices.
description: Async I/O primitives and patterns, non-blocking sockets, fd polling, examples, and best practices.
permalink: /documentation/asyncio/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Async I/O ("asyncio") in Fun
This guide explains the new asynchronous I/O primitives in Fun and how to use them to build non-blocking network and file descriptor workflows. It covers the core concepts, available helpers, common patterns, and runnable examples from the repository.
## What is asyncio in Fun?
In Fun, "asyncio" refers to event-driven, non-blocking I/O built around file descriptor readiness. Instead of blocking on reads/writes, you:
- Put descriptors (sockets, pipes, etc.) into non-blocking mode
- Wait for them to become readable/writable using polling helpers
- Perform small, incremental reads/writes when the OS signals readiness
This lets a single Fun script handle many concurrent connections efficiently without threads, and keeps UIs or other work responsive while I/O is in flight.
There is no special syntax (like async/await) — you compose ordinary control flow with a few focused opcodes and stdlib functions.
However, for more ergonomic, "await-like" workflows without changing the VM, a tiny cooperative scheduler is provided in the stdlib at lib/async/scheduler.fun. It lets you write small step functions that advance per tick and use await_read/await_write wrappers for readability.
## Building blocks
Core helpers wired into the VM (see src/vm/os/*):
- fd_set_nonblock(fd, on) → 1/0: enable or disable O_NONBLOCK on a file descriptor
- fd_poll_read(fd, timeout_ms) → int: >0 if fd is readable; 0 on timeout; <0 on error
- fd_poll_write(fd, timeout_ms) → int: >0 if fd is writable; 0 on timeout; <0 on error
Common networking helpers from the stdlib:
- tcp_connect(host, port) → fd: open a TCP connection; returns 0 on failure
- sock_send(fd, data) → int: send bytes (may write only part in non-blocking mode)
- sock_recv(fd, max_bytes) → string: receive up to max_bytes; empty string on EOF
- sock_close(fd): close the descriptor
Tip: Always check return values. In non-blocking mode, partial writes and short reads are normal.
## Typical patterns
1) Connect and switch to non-blocking
```
fd = tcp_connect(host, port)
if (fd == 0)
// handle connect error
ok = fd_set_nonblock(fd, 1)
if (ok == 0)
// handle mode switch error
```
2) Non-blocking write loop with readiness polling
```
remaining = req
while (len(remaining) > 0)
wr = fd_poll_write(fd, 1000) // wait up to 1s
if (wr < 0)
// poll error; abort
if (wr == 0)
continue // timeout; try again
n = sock_send(fd, remaining)
if (n < 0)
// send error; abort
remaining = substr(remaining, n, len(remaining) - n)
```
3) Non-blocking read-until-close
```
buf = ""
while (true)
rd = fd_poll_read(fd, 2000) // wait up to 2s
if (rd < 0)
// poll error; break
if (rd == 0)
// timeout: try a read to detect EOF
data = sock_recv(fd, 4096)
if (len(data) == 0)
break // likely closed
buf = buf + data
continue
data = sock_recv(fd, 4096)
if (len(data) == 0)
break // closed
buf = buf + data
```
## Timeouts and responsiveness
- timeout_ms controls how long poll waits. Use small timeouts inside loops to interleave work across multiple sockets or tasks.
- A timeout result (0) is not an error — treat it as an opportunity to perform other duties and try again later.
- Negative results (<0) indicate OS-level errors from poll/select; handle or abort as appropriate.
## Working with multiple connections
To multiplex several sockets:
- Keep per-connection state (outgoing buffer, accumulate incoming, progress markers)
- Round-robin over connections, polling each for read/write readiness with short timeouts
- Advance each state machine a little per iteration
Because Fun keeps the primitives low-level and explicit, you can build simple cooperative schedulers, connection pools, or protocol handlers directly in Fun code.
## Examples in the repository
- examples/io/async_http_client.fun — Minimal HTTP GET over non-blocking TCP using fd_poll_* helpers
- examples/io/await_http_client.fun — Same goal, but written using lib/async/scheduler.fun with await_* helpers
- examples/net/http_mt_server.fun — Multi-tenant HTTP server scaffold (compare patterns for concurrency)
- examples/net/http_mt_server_cgi.fun — Server variant that dispatches CGI-like handlers
- lib/net/http_cgi_server.fun — Library helpers used by the server examples
Run client example from a build tree:
```
FUN_LIB_DIR=./lib ./build/fun examples/io/async_http_client.fun
```
If installed system-wide, just:
```
fun /usr/share/fun/examples/io/async_http_client.fun
```
Or to try the await-style client using the cooperative scheduler:
```
FUN_LIB_DIR=./lib ./build/fun examples/io/await_http_client.fun
```
## Cooperative scheduler helpers (library-level)
The file lib/async/scheduler.fun provides a minimal cooperative scheduler built on the existing primitives. There is no VM-level suspension: each task is a small state machine advanced one step per tick. API summary:
- task_spawn(step_fn, state_map) → task_handle
- Registers a task. step_fn is a function that takes a Map state; mutate state and set state.done = 1 when complete.
- run_once() → 1
- Performs one scheduling tick over all runnable tasks.
- run_until_done() → 1
- Repeats run_once() with a tiny sleep_ms(1) until all tasks finish.
- await_read(fd, timeout_ms) → int
- Wrapper over fd_poll_read; returns 1 if readable, 0 on timeout/EOF, -1 on error.
- await_write(fd, timeout_ms) → int
- Wrapper over fd_poll_write; returns 1 if writable, 0 on timeout, -1 on error.
- yield() → 1
- No-op helper to make intent explicit in step functions.
- async_sleep_mark(state, ms) → 1
- Mark the task to be skipped for roughly ms milliseconds; cleared automatically when it wakes.
Example skeleton using the scheduler:
```
#include <async/scheduler.fun>
fun my_task_step(t)
if (t.phase == nil)
t.phase = 0
if (t.phase == 0)
t.fd = tcp_connect("example.org", 80)
if (t.fd == 0)
t.done = 1
return
fd_set_nonblock(t.fd, 1)
t.phase = 1
return
if (t.phase == 1)
if (await_write(t.fd, 50) == 1)
sock_send(t.fd, "GET / HTTP/1.1\r\nHost: example.org\r\n\r\n")
t.buf = ""
t.phase = 2
return
if (t.phase == 2)
rd = await_read(t.fd, 100)
if (rd < 0)
t.done = 1
return
if (rd == 0)
// try a small read to detect EOF
data = sock_recv(t.fd, 4096)
if (len(data) == 0)
t.done = 1
else
t.buf = t.buf + data
return
// readable
data = sock_recv(t.fd, 4096)
if (len(data) == 0)
t.done = 1
else
t.buf = t.buf + data
return
task = task_spawn(my_task_step, {})
run_until_done()
```
This approach is 100% compatible with current runtimes and serves as a stepping stone towards potential future VM-level async/await opcodes.
## Error handling and cleanup
- Always close descriptors with sock_close(fd) when finished or on error paths.
- Distinguish between timeout (wr/rd == 0), EOF (len(recv) == 0), and errors (wr/rd < 0 or send < 0).
- For large payloads, design your loops to tolerate partial progress and resume cleanly.
## FAQ
Q: Is there an async/await syntax?
A: Not at this time. The model is explicit non-blocking I/O with polling helpers. You can build lightweight schedulers on top if desired.
Q: Does this work on all platforms?
A: The helpers map to portable OS facilities exposed by the VM. Details may vary by platform; see documentation/troubleshooting.md and open an issue if you hit differences.
Q: How do I integrate with the REPL?
A: You can prototype small non-blocking fragments in the REPL, but full networking examples are easier to run as scripts.
## See also
- [examples.md](./examples/) — Running bundled examples
- [includes.md](./includes/) — Include paths and library discovery
- [opcodes.md](./opcodes/) — VM opcodes overview
- [troubleshooting.md](./troubleshooting/) — Common issues and quick fixes

115
web/documentation/build.md Normal file
View file

@ -0,0 +1,115 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Building Fun
subtitle: How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
description: How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
permalink: /documentation/build/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Building Fun
This guide describes how to build Fun from source using CMake and the available build options.
## Prerequisites
- A C compiler with C99 support
- CMake 3.20+ (or newer)
- Optional: Rust toolchain with cargo (required when building with `FUN_WITH_RUST=ON`)
## Common targets
- `build` - aggregate target that depends on `fun`, `fun_test`, and `test_opcodes`
- `fun` - the CLI executable
- `fun_test` - unit/feature tests (run with CTest)
- `test_opcodes` - opcode tests (executable)
These targets are defined by the project; use your configured CMake build directory/profile.
## Build options
Fun exposes several options you can toggle at configure time:
- `FUN_DEBUG` (ON/OFF) - Enables extra assertions and logging in the VM and runtime
- `FUN_USE_MUSL` (ON/OFF) - Link against musl for static/portable builds (Linux)
- `FUN_WITH_CPP` (ON/OFF) - Enable C++-based opcode/examples support
- `FUN_WITH_RUST` (ON/OFF) - Build and link Rust staticlib from `src/rust/`
- `FUN_WITH_OPENSSL` (ON/OFF) - Enable OpenSSL-backed helpers (MD5/SHA-256/SHA-512/RIPEMD-160)
### VM configuration constants
You can override internal VM limits at compile time by passing `-D<VAR>=<VALUE>` to CMake:
- `MAX_FRAMES` (default: 128) - Maximum depth of the call stack (frames)
- `MAX_FRAME_LOCALS` (default: 64) - Maximum number of local variables per frame
- `MAX_GLOBALS` (default: 128) - Maximum number of global variables
- `OUTPUT_SIZE` (default: 1024) - Size of the VM output buffer (number of values)
- `STACK_SIZE` (default: 1024) - Size of the VM evaluation stack (number of `Value` slots)
These are defined as `CACHE` variables, so they will persist in your `CMakeCache.txt`.
When configuring, the build prints a summary like:
```
==== Fun build options ====
FUN_DEBUG: ENABLED|DISABLED
FUN_USE_MUSL: ENABLED|DISABLED
FUN_WITH_CPP: ENABLED|DISABLED
FUN_WITH_RUST: ENABLED|DISABLED
===========================
```
## Example commands
Use the CLion-provided build directories or your own. Typical invocations:
### Debug
```
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug \
-DFUN_DEBUG=ON -DFUN_WITH_RUST=OFF
cmake --build build --target build
```
### Release
```
cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
-DFUN_DEBUG=OFF -DFUN_WITH_RUST=OFF
cmake --build build_release --target build
```
### Enabling optional extensions
```
cmake -S . -B build_release -DCMAKE_BUILD_TYPE=Release \
-DFUN_WITH_CPP=ON -DFUN_WITH_RUST=ON -DFUN_WITH_OPENSSL=ON
cmake --build build_release --target build
```
### Customizing VM limits
```
cmake -S . -B build_custom -DSTACK_SIZE=4096 -DMAX_GLOBALS=512
cmake --build build_custom --target fun
```
If `FUN_WITH_RUST` is enabled, ensure `cargo` is available in PATH; the build will invoke it and link the produced static library.
If `FUN_WITH_OPENSSL` is enabled, CMake must detect your system OpenSSL (libcrypto).
## Running
- CLI: run the `fun` executable from your build directory.
- REPL: `fun -i` or just run `fun` without a script, depending on your CLI version (see [cli.md](./cli/)).
- Examples: see [examples.md](./examples/).
Tip: When running from the repository without installation, set `FUN_LIB_DIR` to the local `./lib` so includes can find the stdlib.

View file

@ -0,0 +1,55 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Bytecode Format (Overview)
subtitle: Reference for the bytecode format (split out from internals for convenience).
description: Reference for the bytecode format (split out from internals for convenience).
permalink: /documentation/bytecode-format/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Bytecode Format (Overview)
This document summarizes the Fun bytecode format. For deep VM details, see [internals.md](./internals/).
## Goals
- Compact representation for fast loading and dispatch
- Stable header with room for versioning
## File layout (typical)
1. Header
- Magic number / signature
- Format version
- Flags (endianness, feature bits)
- Offsets to sections
2. Constants table
- Literals: numbers, strings, compound constants
3. Code section
- Functions/procedures with instruction streams
- Line/column mapping (optional for debugging)
4. Auxiliary tables
- Imports/exports, names, debug info (optional)
## Instructions
- Fixed-size or small-variant opcodes grouped by domain (math, logic, stack, call, control flow, etc.).
- Operands encoded inline following the opcode (width varies by instruction).
## Versioning and compatibility
- The header's version field allows the VM to refuse or translate older/newer formats.
- Keep additions backward-compatible when possible by appending sections or flags.

66
web/documentation/cli.md Normal file
View file

@ -0,0 +1,66 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Fun CLI
subtitle: Command-line usage of the `fun` executable, synopsis, options, exit codes, includes and library paths.
description: Command-line usage of the `fun` executable, synopsis, options, exit codes, includes and library paths.
permalink: /documentation/cli/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Fun CLI
Reference for the `fun` command-line interface.
For a complete usage guide (including REPL details, environment variables, include paths, examples, and install locations), see [fun.md](./fun/).
## Synopsis
```
fun [options] <script.fun> [-- args...]
```
If no script is supplied and interactive mode is available, `fun` starts a REPL (see [repl.md](./repl/)).
## Common options
- `-i`, `--repl` - start an interactive REPL
- `-v`, `--version` - print version and exit
- `-h`, `--help` - show help and exit
Options may vary between versions; run `fun --help` to see what your build supports.
## Exit codes
- `0` - success
- non-zero - error during parse, compile, or runtime
## Includes and library paths
- `FUN_LIB_DIR` - environment variable that points to the stdlib location; when running from the repo, set this to `./lib`.
- `DEFAULT_LIB_DIR` - compiled-in fallback path determined at build/install time.
See also: [includes.md](./includes/) for namespaced includes and search order.
## Examples
Run a script:
```
FUN_LIB_DIR=./lib ./build/fun examples/hello.fun
```
Start the REPL:
```
./build/fun -i
```

View file

@ -0,0 +1,66 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Contributing to Fun
subtitle: How to contribute, project structure, coding style, running tests, and PR guidelines.
description: How to contribute, project structure, coding style, running tests, and PR guidelines.
permalink: /documentation/contributing/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Contributing to Fun
Thanks for your interest in contributing! This guide covers the basics to get you productive quickly.
## Getting started
- Clone the repo and build (see [build.md](./build/)).
- Run tests locally (see [testing.md](./testing/)).
- Explore examples (see [examples.md](./examples/)).
## Project structure
- `src/` - C core, VM, and opcode implementations ([src/vm](../src/vm/)).
- `lib/` - Standard library written in Fun.
- `examples/` - Example programs and showcases.
- `documentation/` - Documentation.
- `spec/` - Language specification drafts.
## Code style
- C: C99, two-space indent, no tabs. Keep functions short and focused.
- Fun: two-space indent, snake_case for functions, PascalCase for classes/constructors.
- Prefer clear names over abbreviations. See [style-guide.md](./style-guide/).
## Development workflow
1. Create a small, focused branch.
2. Add/adjust tests for behavior changes (see [writing-tests.md](./writing-tests/)).
3. Update docs if user-visible behavior changes.
4. Submit a PR with a clear description and rationale.
## Commit/PR guidelines
- Keep commits atomic; include test updates with the change.
- Reference related issues.
- Include benchmarks only when meaningful and reproducible.
## Reporting bugs
Please include:
- Reproducer script (minimal), expected vs. actual behavior
- Build options and platform
- `fun --version` output
## Code of Conduct
Be respectful and inclusive. See [CODE_OF_CONDUCT.md](../CODE_OF_CONDUCT/) in the repository root.

View file

@ -4,9 +4,9 @@ published: true
noToc: true
noComments: false
noDate: false
title: Documentation
subtitle: Some documentation about the Fun programming language.
description: The Fun Documentation
title: Fun - Documentation
subtitle: Detailed documentation for the Fun programming language.
description: The Fun Documentation Index
permalink: /documentation/
lang: en
tags:
@ -24,26 +24,71 @@ tags:
- repl
---
# Fun Documentation Index
This file serves as an index of the documents in this directory. Links are relative and can be opened directly on Git hosting or locally.
## Basics
[The Fun Handbook is found here](https://git.xw3.org/fun/fun/src/branch/main/docs/handbook.md){:class="git"}!
Look at [https://git.xw3.org/fun/fun/src/branch/main/docs](https://git.xw3.org/fun/fun/src/branch/main/docs){:class="git"} for more detailed documentation!
## More information
- [handbook.md](./handbook.md) - Comprehensive handbook for the Fun language and VM: install/build, configuration flags, usage, and full feature overview.
- [Fun REPL Guide](./repl.md) - REPL guide: how to build/launch, editing and history, completions, REPL-on-error, and tips.
- [Specification v0.3](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.3.md){:class="git"}
- [Specification v0.2](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.2.md){:class="git"}
- [Specification v0.1](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.1.md){:class="git"}
- [Examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}
- [Standard Library](https://git.xw3.org/fun/fun/src/branch/main/lib){:class="git"}
- [Fun REPL Guide](https://git.xw3.org/fun/fun/src/branch/main/docs/repl.md){:class="git"}
The examples directory contains demonstrations of most Fun features, from basic "Hello, World!" to threading, networking, classes, and more. The lib directory includes modules written in Fun itself.
## For Developers
## Overview
- [Fun Internals](https://git.xw3.org/fun/fun/src/branch/main/docs/internals.md){:class="git"}
- [Fun Opcodes](https://git.xw3.org/fun/fun/src/branch/main/docs/opcodes.md){:class="git"}
- [Basic Rust Opcodes Support](https://git.xw3.org/fun/fun/src/branch/main/docs/rust.md){:class="git"}
- [types.md](./types.md) - Core types (numbers, strings, arrays, maps, nil/bool), common operations, patterns, and interop notes.
- [numbers.md](./numbers.md) - Working with integers and floats: arithmetic, conversions, clamping, bitwise ops, and patterns.
- [strings.md](./strings.md) - Working with strings: literals/escaping, concatenation, substr/find, split, and conversions.
- [arrays.md](./arrays.md) - Working with arrays: creation, indexing/slicing, iteration patterns, helpers, and idioms.
- [maps.md](./maps.md) - Working with maps: construction, lookup/update, merging, iteration, and common patterns.
- [includes.md](./includes.md) - Using local vs. system includes, FUN_LIB_DIR, DEFAULT_LIB_DIR, and namespaced includes with `as`.
- [opcodes.md](./opcodes.md) - VM opcodes overview grouped by domain with brief behavior/stack notes.
- [internals.md](./internals.md) - Implementation details: bytecode format, VM architecture, stacks/frames, parser, and dispatch.
- [rust.md](./rust.md) - Writing Rust-backed opcodes and wiring them into the C VM; build/setup notes.
- [examples.md](./examples.md) - How to run the examples and the interactive showcase script, with environment tips.
- [testing.md](./testing.md) - How to build and run tests/targets with CMake/CTest, and where to add new tests.
- [troubleshooting.md](./troubleshooting.md) - Common issues and quick fixes for build, includes, and REPL usage.
## New and supplemental guides
- [build.md](./build.md) - How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
- [cli.md](./cli.md) - Command-line usage of the `fun` executable: synopsis, options, exit codes, includes and library paths.
- [fun.md](./fun.md) - Full usage guide for the `fun` executable: invocation patterns, REPL, env vars, include paths, examples, and install locations.
- [asyncio.md](./asyncio.md) - Async I/O primitives and patterns: non-blocking sockets, fd polling, examples, and best practices.
- [funstx.md](./funstx.md) - Syntax checker for .fun files with optional --fix auto-corrections; usage, exit codes, and limitations.
- [contributing.md](./contributing.md) - How to contribute: project structure, coding style, running tests, and PR guidelines.
- [style-guide.md](./style-guide.md) - Coding conventions for C and Fun (indentation, naming, idioms).
- [stdlib.md](./stdlib.md) - Overview of the standard library modules under ./lib with one-line summaries.
- [embedding.md](./embedding.md) - Embedding the VM from C/Rust, lifecycle, and host integration tips.
- [errors-and-diagnostics.md](./errors-and-diagnostics.md) - Understanding parser/runtime errors and enabling diagnostics.
- [performance.md](./performance.md) - Build/runtime tuning tips and patterns for better performance.
- [security-and-sandboxing.md](./security-and-sandboxing.md) - Trust boundaries, I/O expectations, and capability restrictions.
- [faq.md](./faq.md) - Frequently asked questions and quick answers.
- [website.md](./website.md) - Documentation for the [fun-lang.xyz](https://fun-lang.xyz) website in the `./web/` directory.
- [writing-tests.md](./writing-tests.md) - How to author new tests for Fun and opcode components.
- [bytecode-format.md](./bytecode-format.md) - Reference for the bytecode format (split out from internals for convenience).
- [roadmap.md](./roadmap.md) - High-level direction, planned features, and pointers to issues.
## Examples
- [examples/README.md](./examples/README.md) - Catalog of all example scripts under ./examples/: what each area contains, how to run them, required env vars, and extension requirements.
## External extensions
Documentation for optional, build-time selectable integrations lives in [external/](./external/):
- [Index of extensions](./external/README.md)
- Highlights: [cURL](./external/curl.md), [INI](./external/ini.md), [JSON](./external/json.md), [XML (libxml2)](./external/xml2.md), [SQLite](./external/sqlite.md), [PCRE2](./external/pcre2.md), [PC/SC](./external/pcsc.md), [OpenSSL](./external/openssl.md)
## Tips
- When building from the repo without installing, set `FUN_LIB_DIR` to the local `./lib` directory so examples and the REPL can locate the stdlib.
- For a broader project overview and quickstart, see the repository root [README.md](../../README.md).
- Crypto examples:
- If built with `-DFUN_WITH_OPENSSL=ON`, try `examples/crypto/openssl_md5.fun`.

View file

@ -0,0 +1,55 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Embedding Fun
subtitle: Embedding the VM from C/Rust, lifecycle, and host integration tips.
description: Embedding the VM from C/Rust, lifecycle, and host integration tips.
permalink: /documentation/embedding/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Embedding Fun
This guide outlines how to embed the Fun VM in a host application and extend it from C/Rust.
## Overview
- The VM is implemented in C (see [src/vm](../src/vm/)).
- Optional Rust-based opcodes can be enabled via `FUN_WITH_RUST` (see [rust.md](./rust/)).
## Embedding from C
While the exact API surface may evolve, a typical embedding flow looks like:
1. Initialize the VM/runtime and allocate a context.
2. Load/compile Fun source or bytecode.
3. Push arguments or set globals as needed.
4. Execute entry function or script body.
5. Retrieve results and clean up.
See [src/vm/core](../src/vm/core/) and related headers for public entry points and value types.
### Hosting considerations
- Threading: share VM state cautiously or create one VM per thread.
- Memory: clarify ownership of strings/buffers crossing the boundary.
- Errors: propagate parse/runtime errors back to the host with useful messages.
## Extending with Rust
When `FUN_WITH_RUST=ON`, a Rust static library from [`src/rust/`](../src/rust/) is built and linked. You can:
- Implement new opcodes/functions in Rust.
- Expose a C ABI for the VM to call into.
See [rust.md](./rust/) for details and example code.

View file

@ -0,0 +1,47 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Errors and Diagnostics
subtitle: Understanding parser/runtime errors and enabling diagnostics.
description: Understanding parser/runtime errors and enabling diagnostics.
permalink: /documentation/errors-and-diagnostics/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Errors and Diagnostics
This guide helps you understand common error messages and how to collect useful diagnostics.
## Common error classes
- Parse errors: syntax/indentation problems detected before execution.
- Name/lookup errors: missing variables, functions, or modules.
- Runtime errors: type mismatches, out-of-range access, invalid operations.
## Enabling diagnostics
- Build with `-DFUN_DEBUG=ON` to enable additional assertions and debug messages (see [build.md](./build/)).
- Run with smaller, focused scripts to isolate issues.
## Getting useful reports
- Capture the minimal script that reproduces the issue.
- Note your build options and platform.
- Record the full error output from the CLI (`fun`), including line/column if present.
## Tips
- Use prints or logging sparingly to narrow down failing code.
- Start from a passing simple case and add complexity until it breaks.

View file

@ -0,0 +1,89 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Running the Examples
subtitle: How to run the examples and the interactive showcase script, with environment tips.
description: How to run the examples and the interactive showcase script, with environment tips.
permalink: /documentation/examples/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Running the Examples
This page shows how to run the example programs included with the repository and how to use the interactive showcase script.
All commands assume you are in the repository root.
## Prerequisites
- Build the interpreter (see handbook.md). Youll have `build/fun` (paths may vary by your setup/IDE).
- Set FUN_LIB_DIR to the repos lib directory when running without installation so `#include <...>` can find the standard library.
Example (Linux/macOS/BSD):
```
FUN_LIB_DIR="$(pwd)/lib" ./build/fun examples/include_lib.fun
```
Windows (PowerShell):
```
$env:FUN_LIB_DIR = "$PWD/lib"
./build/fun.exe .\examples\include_lib.fun
```
## Interactive showcase: play.fun
The script `./play.fun` discovers all `.fun` files under `./examples` and offers to run them one by one:
```
./play.fun
```
Notes:
- The script auto-picks your interpreter (FUN_BIN env or `fun` in PATH) and ensures `FUN_LIB_DIR=./lib` so examples resolve includes correctly.
- It shows the exit code for each run and summarizes failures at the end.
Tip: you can run specific examples directly too:
```
FUN_LIB_DIR="$(pwd)/lib" fun examples/crypto/openssl_md5.fun
```
## Example categories
Browse the `examples/` tree for areas of interest:
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512/RIPEMD160 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
- blocking / interactive — I/O or user-interactive patterns
- error / broken — negative tests and error showcases
- math — numeric operations
- sqlited / data — data access and HTTP/CGI-style samples (platform dependent)
## Creating your own examples
Place your `.fun` files anywhere under `examples/` to have them picked up by `play.fun`. Use quoted includes for project-local helpers and angle brackets for stdlib modules:
```
#include "examples/my_lib/common.fun"
#include <io/console.fun>
```
If you add an example showcasing a new feature, also consider adding a brief note to the relevant doc (types.md, includes.md, opcodes.md, etc.).

View file

@ -0,0 +1,244 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - Examples catalog and how to run them
subtitle: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements.
description: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements.
permalink: /documentation/examples/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# Examples catalog and how to run them
This page is a practical catalog of the example areas that ship with the Fun language. It explains what youll find in each folder under ./examples/, how to run the scripts, and where deeper walkthroughs live.
If youre building/running from the repository without installing, set FUN_LIB_DIR to the local ./lib directory so examples can locate the stdlib:
- export FUN_LIB_DIR="./lib"
- Then run an example: ./build_debug/fun examples/basics/hello_world.fun
- Or, if installed: fun examples/basics/hello_world.fun
Notes
- Most scripts are selfdocumented with a short header comment at the top. Open them to see exact behavior and expected output.
- Some examples depend on optional extensions (cURL, PCRE2, SQLite, Notcurses, Tk, PC/SC, OpenSSL/LibreSSL). See documentation/external/ for enablement and availability.
- Networking examples often bind to 127.0.0.1 on high ports; read the file header for the exact port.
Deepdives
## Toplevel examples (./examples)
Quick micro demos covering language features and tiny utilities.
Run pattern:
- fun examples/<file>.fun
Highlights (selection):
- [builtins_extended.fun](./builtins_extended/) — tour of core builtins beyond the basics
- [byte_for_demo.fun](./byte_for_demo/) — iterating bytes with for
- [byte_overflow_try_catch.fun](./byte_overflow_try_catch/) — error handling on overflow
- [cast_demo.fun](./cast_demo/) — conversions and casting helpers
- [class_constructor.fun](./class_constructor/) — basic constructor usage and init patterns
- [class_test.fun](./class_test/) — small class feature checks
- [classes_demo.fun](classes_demo/) — class basics and usage
- [class_without_object.fun](./class_without_object/) — class features without an instance helper
- [cli_argv_dump.fun](./cli_argv_dump/) — prints argv/argc handling
- [conversions_showcase.fun](./conversions_showcase/) — numbers, strings, bytes conversions
- [cpp_add.fun](./cpp_add/) — calling into the optional C++ extension (if enabled)
- [datetime_basic.fun](./datetime_basic/) — minimal date/time helpers
- [datetime_extended.fun](./datetime_extended/) — richer date/time operations
- [datetime_timer.fun](datetime_timer/) — time/date helpers
- [echo_example.fun](./echo_example/) — simple echo of input/args
- [env_all.fun](./env_all/) — enumerate environment variables
- [os_env.fun](./os_env/) — reading environment variables
- [error_handling.fun](./error_handling/) — try/catch and error objects
- [try_catch_finally.fun](try_catch_finally/) — error patterns
- [expressions_test.fun](./expressions_test/) — precedence and grouping
- [features.fun](./features/) — grab bag of language features
- [file_print_for_file_line_by_line.fun](./file_print_for_file_line_by_line/) — iterate file content
- [floats.fun](./floats/) — float ops and formatting
- [for_range_test.fun](./for_range_test/) — ranges and loops
- [functions_test.fun](./functions_test/) — functions, closures, returns
- [have_fun.fun](./have_fun/) — playful starter demo
- [have_fun_function.fun](have_fun_function/) — playful demos
- [hex_example.fun](./hex_example/) — hex encode/decode
- [if_else_test.fun](./if_else_test/) — conditional branching examples
- [nested_loops.fun](./nested_loops/) — loops inside loops
- [loops_break_continue.fun](loops_break_continue/) — control flow
- [include_local.fun](./include_local/) — include a local file/module
- [include_lib.fun](./include_lib/) — include from the stdlib path
- [include_local_util.fun](include_local_util/) — include mechanics
- [inheritance_demo.fun](./inheritance_demo/) — simple class inheritance
- [maps.fun](./maps/), [match.fun](match/) — data structures and pattern matching
- [namespaced_mod.fun](./namespaced_mod/) — namespaced includes with as
- [objects_basic.fun](./objects_basic/) — simple objects and methods
- [objects_more.fun](./objects_more/) — OO basics
- [process_example.fun](./process_example/) — spawn and capture subprocess output
- [progress.fun](./progress/) — progress bar helper
- [progress_inline.fun](./progress_inline/) — simple progress displays
- [random_demo.fun](./random_demo/) — random helpers overview
- [random_number_example.fun](random_number_example/) — RNG usage
- [regex_demo.fun](./regex_demo/) — regex basics (PCRE2 when enabled)
- [regex_procedural.fun](./regex_procedural/) — regex helpers (PCRE2 when enabled)
- [rust_hello.fun](./rust_hello/), rust_hello_args*.fun — Rust opcodes (if FUN_WITH_RUST)
- [serial_demo.fun](./serial_demo/) — serial port usage
- [test_serial.fun](./test_serial/) — serial port (when available)
- [short_circuit_test.fun](./short_circuit_test/) — boolean evaluation order
- [signed_ints.fun](./signed_ints/) — signed integers overview
- [uint_types.fun](./uint_types/) — unsigned integers overview
- [types_integers.fun](./types_integers/) — integer families
- [stdlib_showcase.fun](./stdlib_showcase/) — sampler of common stdlib modules
- [strings_test.fun](./strings_test/) — string helpers and edge cases
- [tcp_http_get.fun](./tcp_http_get/) — simple HTTP GET over raw TCP
- [tcp_http_get_class.fun](./tcp_http_get_class/) — manual HTTP client over sockets
- [test_bits.fun](./test_bits/) — /rol/shl/xor/dec_to_hex/hex_to_dec bitwise utilities
- [thread_class_example.fun](./thread_class_example/) — define and run a thread class
- [threads_demo.fun](./threads_demo/) — threading building blocks
- [typeof.fun](./typeof/) — type inspection
- [typeof_features.fun](./typeof_features/) — type inspection of declared integer subtypes and runtime categories
- [type_safety.fun](./type_safety/) — static/dynamic type checks
- [type_safety_fails.fun](./type_safety_fails/) — static/dynamic type checks
- [types_overview.fun](./types_overview/) — language types tour
- [unix_socket_echo.fun](./unix_socket_echo/) — local domain socket echo demo
- [version.fun](./version/) — print VM/version info
- [while_test.fun](./while_test/) — simple while loop example
Tip: If a file name is listed above but not present on your build, it may depend on an extension you did not enable.
## Algorithms (./examples/algos)
- deduplicate.fun — removing duplicates from arrays/maps
- sort_and_search.fun — sorting and lookup patterns
- stack_queue.fun — basic stack and queue implementation
## Arrays (./examples/arrays)
- arrays.fun — create, index, slice; typical idioms
- arrays_iter.fun — iteration and enumeration
- arrays_advanced.fun — copying, filtering, transformations
## Basics (./examples/basics)
- boolean_decl.fun, booleans.fun — boolean values and operators
- builtins_conversions.fun — core builtins, type conversions
- collections.fun — arrays, maps, nested structures
- fibonacci.fun, fizzbuzz.fun — classic exercises
- hello_world.fun — the canonical first program
## CLI (./examples/cli)
- args_parse.fun — arguments parsing patterns for small CLIs
## Compose (./examples/compose)
Compositional patterns, small abstractions to combine behavior.
## Crypto (./examples/crypto)
Hashing and cryptographic helpers. Availability depends on whether OpenSSL/LibreSSL is enabled.
- openssl_md5.fun — MD5 via OpenSSL (if -DFUN_WITH_OPENSSL)
- libressl_md5.fun — MD5 via LibreSSL (if -DFUN_WITH_LIBRESSL)
- aes256.fun and hash samples if present on your build
## Data (./examples/data)
Static assets for example servers; not meant to be run directly.
- htdocumentation/ — files used by HTTP server examples (index.html, hello.fun, info.fun, form_post.fun, counter.fun, redirect.fun, json_like_api.fun)
## Error handling and diagnostics (./examples/error)
- debug_reporting.fun — enabling debug output and reading traces
- exit_example.fun — exit codes
- fail.fun — triggering and observing failures
- repl_on_error.fun — dropping into REPL on error
- rust_vm_access.fun — Rust opcode errors (if enabled)
- test_indent.fun — parser/indentation corner cases
- try_catch_with_error.fun — capturing error objects
## Extra integrations (./examples/extra)
These require optional external libraries. See documentation/external/.
- curl_* — cURL HTTP client examples (download, GET JSON, POST)
- ini_* — parsing INI files (simple to complex)
- json_showcase.fun — JSON helpers
- libsql_example.fun — libSQL client usage
- notcurses_* — rich TUI demos (if Notcurses enabled)
- pcre2_* — PCRE2 regex engine demos
- pcsc*.fun — smart card access via PC/SC
- sqlite_example.fun — SQLite usage
- tcp_echo_server*.fun — basic TCP echo server
- tk_* — Tcl/Tk GUI examples
- xml_* — XML parsing with libxml2
## Interactive (./examples/interactive)
- console_prompt.fun — simple prompt loop
- input_example.fun — reading user input
- input_hidden_example.fun, input_hidden_pam_auth.fun — hidden input/passwords
## IO (./examples/io)
- async_http_client.fun — nonblocking HTTP client
- await_http_client.fun — nonblocking HTTP client using lib/async/scheduler.fun (await-style helpers)
- csv_reader.fun — parse CSV files
- file_io.fun, read_write_file.fun — file operations
- word_count.fun — classic WC example
## Math (./examples/math)
Small, focused math helpers and demonstrations:
- math_ceil, math_floor, math_round, math_trunc, math_sign
- math_cos, math_sin, math_tan
- math_sqrt, math_isqrt
- math_exp_log
- math_fmin_fmax
- math_gcd_lcm
## Networking (./examples/net)
Servers and socket utilities. See documentation/examples/net/httpserver.md for the HTTP family.
- HTTP servers: [httpserver.md](./net/httpserver/) — endtoend walkthrough of all HTTP server variants in examples/net/
- http_static_server.fun — minimal static server over sockets
- http_server.fun — blocking static/CGI dispatcher using lib/net/http_server.fun
- http_server_cgi.fun — blocking server with CGI via lib/net/http_cgi_server.fun
- http_server_cgi_lib.fun — blocking server leveraging net/cgi.fun helpers
- http_mt_server.fun — threadperconnection static server
- http_mt_server_cgi.fun — threadperconnection with CGI support
## Patterns (./examples/patterns)
Small idioms and reusable patterns.
- assert_like.fun — assertstyle checks via language constructs
## Snippets (./examples/snippets)
Miscellaneous oneoff code snippets demonstrating particular opcodes or tricks.
## SQLite daemon (./examples/sqlited)
- Files related to running a small SQLitebacked service (see source for details)
## Strings (./examples/strings)
- base64_demo.fun — base64 encode/decode using encoding/base64
- split_join_trim.fun — string splitting and trimming
- templating_min.fun — barebones templating
- urlencode_decode.fun — percentencoding helpers
## Broken (./examples/broken)
Historical or intentionally broken examples kept for reference/regression.
- notcurses_* — experiments around Notcurses
- ripemd160* — legacy or experimental hash routines
### Running examples reliably
Prefer the local build when running from the repository root:
- ./build_debug/fun <path/to/example.fun>
- or: ./build_release/fun <path/to/example.fun>
Set up env if needed:
- export FUN_LIB_DIR="./lib" # to find stdlib
- export FUN_EXEC="./build_debug/fun" # used by CGI examples
- export FUN_HTDOCS="./examples/data/htdocs" # override docroot
When optional extensions are not enabled, their examples will not run; reconfigure the build with the required -D flags shown in documentation/external/.

View file

@ -0,0 +1,39 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - builtins_extended.fun — overview
subtitle: Documentation for builtins_extended.fun — overview
description: Documentation for builtins_extended.fun — overview
permalink: /documentation/examples/builtins_extended/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# builtins_extended.fun — overview
What it shows
- A tour of core builtins beyond the basics: printing, typing, math helpers, conversions, and utility functions commonly used in small scripts.
How to run
- From repo root with local build:
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/builtins_extended.fun
- Or, if installed: fun examples/builtins_extended.fun
Notes
- Exact behavior and outputs are documented inline at the top of the script; open the .fun file for details.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - builtins_maps_and_more.fun — overview
subtitle: Documentation for builtins_maps_and_more.fun — overview
description: Documentation for builtins_maps_and_more.fun — overview
permalink: /documentation/examples/builtins_maps_and_more/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# builtins_maps_and_more.fun — overview
What it shows
- Exploring builtins while working with maps and related data structures.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/builtins_maps_and_more.fun
- Or: fun examples/builtins_maps_and_more.fun
Notes
- Open the .fun file to see the exact behaviors and printed output.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - byte_for_demo.fun — overview
subtitle: Documentation for byte_for_demo.fun — overview
description: Documentation for byte_for_demo.fun — overview
permalink: /documentation/examples/byte_for_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# byte_for_demo.fun — overview
What it shows
- Iterating bytes with a for-loop; indexing and printing byte values.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/byte_for_demo.fun
- Or: fun examples/byte_for_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - byte_overflow_try_catch.fun — overview
subtitle: Documentation for byte_overflow_try_catch.fun — overview
description: Documentation for byte_overflow_try_catch.fun — overview
permalink: /documentation/examples/byte_overflow_try_catch/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# byte_overflow_try_catch.fun — overview
What it shows
- Error handling around byte/integer overflow using try/catch.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/byte_overflow_try_catch.fun
- Or: fun examples/byte_overflow_try_catch.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - cast_demo.fun — overview
subtitle: Documentation for cast_demo.fun — overview
description: Documentation for cast_demo.fun — overview
permalink: /documentation/examples/cast_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# cast_demo.fun — overview
What it shows
- Conversions and casting helpers; demonstrates changing between numeric and string types safely.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/cast_demo.fun
- Or: fun examples/cast_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - class_constructor.fun — overview
subtitle: Documentation for class_constructor.fun — overview
description: Documentation for class_constructor.fun — overview
permalink: /documentation/examples/class_constructor/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# class_constructor.fun — overview
What it shows
- Class basics and constructor behavior; initializing fields and using methods.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/class_constructor.fun
- Or: fun examples/class_constructor.fun

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - class_test.fun — overview
subtitle: Documentation for class_test.fun — overview
description: Documentation for class_test.fun — overview
permalink: /documentation/examples/class_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# class_test.fun — overview
What it shows
- Simple class usage and method invocation; small sanity checks around classes.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/class_test.fun
- Or: fun examples/class_test.fun
Notes
- Open the script to see the exact behavior and outputs.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - class_without_object.fun — overview
subtitle: Documentation for class_without_object.fun — overview
description: Documentation for class_without_object.fun — overview
permalink: /documentation/examples/class_without_object/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# class_without_object.fun — overview
What it shows
- Class features that can be used without creating an instance (static-like usage patterns).
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/class_without_object.fun
- Or: fun examples/class_without_object.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - classes_demo.fun — overview
subtitle: Documentation for classes_demo.fun — overview
description: Documentation for classes_demo.fun — overview
permalink: /documentation/examples/classes_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# classes_demo.fun — overview
What it shows
- Class basics and usage: defining classes, instantiating objects, calling methods.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/classes_demo.fun
- Or: fun examples/classes_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - cli_argv_dump.fun — overview
subtitle: Documentation for cli_argv_dump.fun — overview
description: Documentation for cli_argv_dump.fun — overview
permalink: /documentation/examples/cli_argv_dump/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# cli_argv_dump.fun — overview
What it shows
- Prints argv/argc handling to demonstrate CLI arguments parsing at a low level.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/cli_argv_dump.fun --foo bar 123
- Or: fun examples/cli_argv_dump.fun --foo bar 123

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - conversions_showcase.fun — overview
subtitle: Documentation for conversions_showcase.fun — overview
description: Documentation for conversions_showcase.fun — overview
permalink: /documentation/examples/conversions_showcase/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# conversions_showcase.fun — overview
What it shows
- Numbers, strings, and bytes conversions; typical idioms and edge cases.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/conversions_showcase.fun
- Or: fun examples/conversions_showcase.fun

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - cpp_add.fun — overview
subtitle: Documentation for cpp_add.fun — overview
description: Documentation for cpp_add.fun — overview
permalink: /documentation/examples/cpp_add/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# cpp_add.fun — overview
What it shows
- Calling into the optional C++ extension from Fun.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/cpp_add.fun
- Or: fun examples/cpp_add.fun
Notes
- Requires the optional C++ extension to be enabled in your build; otherwise this example may be unavailable.

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - counter.fun (CGI)
subtitle: Documentation for counter.fun (CGI)
description: Documentation for counter.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/counter/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# counter.fun (CGI)
- Location: examples/data/htdocumentation/counter.fun
- Category: CGI script used by HTTP server examples
Description
- Simple stateful counter example for CGI; demonstrates reading and updating a value across requests (implementation details in script).
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Open: http://127.0.0.1:8080/counter.fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - form_post.fun (CGI)
subtitle: Documentation for form_post.fun (CGI)
description: Documentation for form_post.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/form_post/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# form_post.fun (CGI)
- Location: examples/data/htdocumentation/form_post.fun
- Category: CGI script used by HTTP server examples
Description
- Demonstrates handling of POST form data via the CGI interface.
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Submit a form to: http://127.0.0.1:8080/form_post.fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - hello.fun (CGI)
subtitle: Documentation for hello.fun (CGI)
description: Documentation for hello.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/hello/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# hello.fun (CGI)
- Location: examples/data/htdocumentation/hello.fun
- Category: CGI script used by HTTP server examples
Description
- Simple CGI .fun script that prints a greeting, optionally using query parameters (e.g., ?name=Fun).
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Open: http://127.0.0.1:8080/hello.fun?name=Fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - info.fun (CGI)
subtitle: Documentation for info.fun (CGI)
description: Documentation for info.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/info/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# info.fun (CGI)
- Location: examples/data/htdocumentation/info.fun
- Category: CGI script used by HTTP server examples
Description
- CGI script that prints request/environment information, useful for debugging CGI variables.
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Open: http://127.0.0.1:8080/info.fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - json_like_api.fun (CGI)
subtitle: Documentation for json_like_api.fun (CGI)
description: Documentation for json_like_api.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/json_like_api/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# json_like_api.fun (CGI)
- Location: examples/data/htdocumentation/json_like_api.fun
- Category: CGI script used by HTTP server examples
Description
- Demonstrates returning JSON-like output from a CGI endpoint.
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Open: http://127.0.0.1:8080/json_like_api.fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,43 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - redirect.fun (CGI)
subtitle: Documentation for redirect.fun (CGI)
description: Documentation for redirect.fun (CGI)
permalink: /documentation/examples/data/htdocumentation/redirect/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# redirect.fun (CGI)
- Location: examples/data/htdocumentation/redirect.fun
- Category: CGI script used by HTTP server examples
Description
- Demonstrates issuing HTTP redirects from a CGI script (setting Status and Location headers).
How to run
- Through one of the HTTP server examples, e.g.:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun"
- ./build_debug/fun examples/net/http_server_cgi.fun
- Open: http://127.0.0.1:8080/redirect.fun
See also
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - datetime_basic.fun — overview
subtitle: Documentation for datetime_basic.fun — overview
description: Documentation for datetime_basic.fun — overview
permalink: /documentation/examples/datetime_basic/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# datetime_basic.fun — overview
What it shows
- Basic time/date helpers and formatting.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/datetime_basic.fun
- Or: fun examples/datetime_basic.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - datetime_extended.fun — overview
subtitle: Documentation for datetime_extended.fun — overview
description: Documentation for datetime_extended.fun — overview
permalink: /documentation/examples/datetime_extended/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# datetime_extended.fun — overview
What it shows
- Extended datetime helpers: parsing, arithmetic, timers, and formatting variants.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/datetime_extended.fun
- Or: fun examples/datetime_extended.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - datetime_timer.fun — overview
subtitle: Documentation for datetime_timer.fun — overview
description: Documentation for datetime_timer.fun — overview
permalink: /documentation/examples/datetime_timer/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# datetime_timer.fun — overview
What it shows
- Measuring elapsed time and simple timers using datetime helpers.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/datetime_timer.fun
- Or: fun examples/datetime_timer.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - echo_example.fun — overview
subtitle: Documentation for echo_example.fun — overview
description: Documentation for echo_example.fun — overview
permalink: /documentation/examples/echo_example/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# echo_example.fun — overview
What it shows
- Simple echo of input/args; prints back what you type or pass as arguments.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/echo_example.fun hello world
- Or: fun examples/echo_example.fun hello world

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - env_all.fun — overview
subtitle: Documentation for env_all.fun — overview
description: Documentation for env_all.fun — overview
permalink: /documentation/examples/env_all/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# env_all.fun — overview
What it shows
- Reading and listing environment variables.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/env_all.fun
- Or: fun examples/env_all.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - error_handling.fun — overview
subtitle: Documentation for error_handling.fun — overview
description: Documentation for error_handling.fun — overview
permalink: /documentation/examples/error_handling/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# error_handling.fun — overview
What it shows
- Error patterns and handling strategies using try/catch/finally.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/error_handling.fun
- Or: fun examples/error_handling.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - expressions_test.fun — overview
subtitle: Documentation for expressions_test.fun — overview
description: Documentation for expressions_test.fun — overview
permalink: /documentation/examples/expressions_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# expressions_test.fun — overview
What it shows
- Operator precedence and expression grouping tests/demonstrations.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/expressions_test.fun
- Or: fun examples/expressions_test.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - features.fun — overview
subtitle: Documentation for features.fun — overview
description: Documentation for features.fun — overview
permalink: /documentation/examples/features/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# features.fun — overview
What it shows
- Grab bag of language features in a single script.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/features.fun
- Or: fun examples/features.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - file_print_for_file_line_by_line.fun — overview
subtitle: Documentation for file_print_for_file_line_by_line.fun — overview
description: Documentation for file_print_for_file_line_by_line.fun — overview
permalink: /documentation/examples/file_print_for_file_line_by_line/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# file_print_for_file_line_by_line.fun — overview
What it shows
- Iterate a file line-by-line and print each line; basic file IO idioms.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/file_print_for_file_line_by_line.fun path/to/file.txt
- Or: fun examples/file_print_for_file_line_by_line.fun path/to/file.txt

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - floats.fun — overview
subtitle: Documentation for floats.fun — overview
description: Documentation for floats.fun — overview
permalink: /documentation/examples/floats/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# floats.fun — overview
What it shows
- Floating point operations and formatting details.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/floats.fun
- Or: fun examples/floats.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - for_range_test.fun — overview
subtitle: Documentation for for_range_test.fun — overview
description: Documentation for for_range_test.fun — overview
permalink: /documentation/examples/for_range_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# for_range_test.fun — overview
What it shows
- Ranges and loops; iterating numeric ranges and verifying bounds.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/for_range_test.fun
- Or: fun examples/for_range_test.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - functions_test.fun — overview
subtitle: Documentation for functions_test.fun — overview
description: Documentation for functions_test.fun — overview
permalink: /documentation/examples/functions_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# functions_test.fun — overview
What it shows
- Functions, closures, and return behavior; call semantics basics.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/functions_test.fun
- Or: fun examples/functions_test.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - have_fun.fun — overview
subtitle: Documentation for have_fun.fun — overview
description: Documentation for have_fun.fun — overview
permalink: /documentation/examples/have_fun/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# have_fun.fun — overview
What it shows
- Playful demo showing off small language tricks.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/have_fun.fun
- Or: fun examples/have_fun.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - have_fun_function.fun — overview
subtitle: Documentation for have_fun_function.fun — overview
description: Documentation for have_fun_function.fun — overview
permalink: /documentation/examples/have_fun_function/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# have_fun_function.fun — overview
What it shows
- A playful function-centric demo; small utility behaviors.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/have_fun_function.fun
- Or: fun examples/have_fun_function.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - hex_example.fun — overview
subtitle: Documentation for hex_example.fun — overview
description: Documentation for hex_example.fun — overview
permalink: /documentation/examples/hex_example/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# hex_example.fun — overview
What it shows
- Hex encode/decode helpers; working with hexadecimal representations.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/hex_example.fun
- Or: fun examples/hex_example.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - if_else_test.fun — overview
subtitle: Documentation for if_else_test.fun — overview
description: Documentation for if_else_test.fun — overview
permalink: /documentation/examples/if_else_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# if_else_test.fun — overview
What it shows
- Control flow with if/else; branching and comparisons.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/if_else_test.fun
- Or: fun examples/if_else_test.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - include_lib.fun — overview
subtitle: Documentation for include_lib.fun — overview
description: Documentation for include_lib.fun — overview
permalink: /documentation/examples/include_lib/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# include_lib.fun — overview
What it shows
- Including modules from the standard library path using #include <...>.
How to run
- export FUN_LIB_DIR="./lib" # ensure stdlib is discoverable
- ./build_debug/fun examples/include_lib.fun
- Or: fun examples/include_lib.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - include_local.fun — overview
subtitle: Documentation for include_local.fun — overview
description: Documentation for include_local.fun — overview
permalink: /documentation/examples/include_local/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# include_local.fun — overview
What it shows
- Including local files relative to the script and reusing helpers.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/include_local.fun
- Or: fun examples/include_local.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - include_local_util.fun — overview
subtitle: Documentation for include_local_util.fun — overview
description: Documentation for include_local_util.fun — overview
permalink: /documentation/examples/include_local_util/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# include_local_util.fun — overview
What it shows
- Local include mechanics with a small utility module.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/include_local_util.fun
- Or: fun examples/include_local_util.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - inheritance_demo.fun — overview
subtitle: Documentation for inheritance_demo.fun — overview
description: Documentation for inheritance_demo.fun — overview
permalink: /documentation/examples/inheritance_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# inheritance_demo.fun — overview
What it shows
- Simple class inheritance and method overriding examples.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/inheritance_demo.fun
- Or: fun examples/inheritance_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - loops_break_continue.fun — overview
subtitle: Documentation for loops_break_continue.fun — overview
description: Documentation for loops_break_continue.fun — overview
permalink: /documentation/examples/loops_break_continue/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# loops_break_continue.fun — overview
What it shows
- Loop control: break and continue; demonstrating control flow within loops.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/loops_break_continue.fun
- Or: fun examples/loops_break_continue.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - maps.fun — overview
subtitle: Working with maps, construction, lookup/update, merging, iteration, and common patterns.
description: Working with maps, construction, lookup/update, merging, iteration, and common patterns.
permalink: /documentation/examples/maps/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# maps.fun — overview
What it shows
- Working with maps: creation, indexing, iteration, and typical idioms.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/maps.fun
- Or: fun examples/maps.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - match.fun — overview
subtitle: Documentation for match.fun — overview
description: Documentation for match.fun — overview
permalink: /documentation/examples/match/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# match.fun — overview
What it shows
- Pattern matching constructs and examples of branching by value/shape.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/match.fun
- Or: fun examples/match.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - namespaced_mod.fun — overview
subtitle: Documentation for namespaced_mod.fun — overview
description: Documentation for namespaced_mod.fun — overview
permalink: /documentation/examples/namespaced_mod/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# namespaced_mod.fun — overview
What it shows
- Namespaced includes and using the "as" aliasing pattern for modules.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/namespaced_mod.fun
- Or: fun examples/namespaced_mod.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - nested_loops.fun — overview
subtitle: Documentation for nested_loops.fun — overview
description: Documentation for nested_loops.fun — overview
permalink: /documentation/examples/nested_loops/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# nested_loops.fun — overview
What it shows
- Control flow with nested loops; inner/outer loop coordination.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/nested_loops.fun
- Or: fun examples/nested_loops.fun

View file

@ -0,0 +1,46 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_mt_server.fun
subtitle: Documentation for http_mt_server.fun
description: Documentation for http_mt_server.fun
permalink: /documentation/examples/net/http_mt_server/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_mt_server.fun
- Location: examples/net/http_mt_server.fun
- Category: Networking / HTTP (multi-threaded)
Description
- Thread-per-connection HTTP server built on io/socket.fun and io/thread.fun. For each accepted client, spawns a thread and returns a small HTML page.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/net/http_mt_server.fun
- Then open http://127.0.0.1:8080/ (or the port printed on start)
Requirements
- Uses stdlib io/socket.fun and io/thread.fun. No external extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,48 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_mt_server_cgi.fun
subtitle: Documentation for http_mt_server_cgi.fun
description: Documentation for http_mt_server_cgi.fun
permalink: /documentation/examples/net/http_mt_server_cgi/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_mt_server_cgi.fun
- Location: examples/net/http_mt_server_cgi.fun
- Category: Networking / HTTP with CGI (multi-threaded)
Description
- Multi-threaded HTTP server (thread-per-connection) with CGI support. Serves static files from htdocs and executes .fun scripts as CGI using net/cgi.fun helpers.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun" # optional; auto-detected if omitted
- export FUN_HTDOCS="./examples/data/htdocs" # optional
- ./build_debug/fun examples/net/http_mt_server_cgi.fun
- Try: http://127.0.0.1:8080/ and /hello.fun?name=Fun, /info.fun
Requirements
- Uses stdlib io/socket.fun, io/thread.fun, and net/cgi.fun. No external extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,50 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_server.fun
subtitle: Documentation for http_server.fun
description: Documentation for http_server.fun
permalink: /documentation/examples/net/http_server/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_server.fun
- Location: examples/net/http_server.fun
- Category: Networking / HTTP (blocking)
Description
- Blocking HTTP server that serves static files and executes .fun CGI scripts via lib/net/http_server.fun.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/net/http_server.fun
- Default docroot: ./examples/data/htdocs
- Visit: http://127.0.0.1:8080/
Notes
- For CGI .fun under htdocs, the server uses the Fun interpreter to execute them and forwards output as HTTP.
Requirements
- Uses io/socket.fun and strings.fun; no external extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,48 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_server_cgi.fun
subtitle: Documentation for http_server_cgi.fun
description: Documentation for http_server_cgi.fun
permalink: /documentation/examples/net/http_server_cgi/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_server_cgi.fun
- Location: examples/net/http_server_cgi.fun
- Category: Networking / HTTP with CGI (blocking)
Description
- Minimal CGI-capable HTTP server (blocking) using lib/net/http_cgi_server.fun. Serves static files and executes .fun scripts as CGI.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun" # optional; auto-detected if omitted
- export FUN_HTDOCS="./examples/data/htdocs" # optional
- ./build_debug/fun examples/net/http_server_cgi.fun
- Try: http://127.0.0.1:8080/ and /hello.fun, /info.fun
Requirements
- Uses stdlib io/socket.fun, strings.fun, and net/cgi.fun. No external extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,48 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_server_cgi_lib.fun
subtitle: Documentation for http_server_cgi_lib.fun
description: Documentation for http_server_cgi_lib.fun
permalink: /documentation/examples/net/http_server_cgi_lib/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_server_cgi_lib.fun
- Location: examples/net/http_server_cgi_lib.fun
- Category: Networking / HTTP with CGI (blocking, stdlib helpers)
Description
- Blocking HTTP server that serves static files and runs .fun as CGI using helpers from lib/net/http_cgi_lib_server.fun and net/cgi.fun.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- export FUN_EXEC="./build_debug/fun" # optional; auto-detected if omitted
- export FUN_HTDOCS="./examples/data/htdocs" # optional
- ./build_debug/fun examples/net/http_server_cgi_lib.fun
- Try: http://127.0.0.1:8080/ and /hello.fun, /info.fun
Requirements
- Uses stdlib io/socket.fun, strings.fun, net/cgi.fun. No external extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive)

View file

@ -0,0 +1,46 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - http_static_server.fun
subtitle: Documentation for http_static_server.fun
description: Documentation for http_static_server.fun
permalink: /documentation/examples/net/http_static_server/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# http_static_server.fun
- Location: examples/net/http_static_server.fun
- Category: Networking / Sockets
Description
- Minimal static HTTP server implemented directly on sockets. Accepts connections and always returns a small HTML page.
How to run
- From the repository root:
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/net/http_static_server.fun
- Then open http://127.0.0.1:8088/
Requirements
- Uses core IO/socket stdlib (io/socket.fun). No optional extensions required.
See also
- documentation/examples/README.md
- documentation/examples/httpserver.md (deep-dive over HTTP servers)

View file

@ -0,0 +1,160 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - HTTP server examples: architecture and how they work
subtitle: Documentation for HTTP server examples, architecture and how they work
description: Documentation for HTTP server examples, architecture and how they work
permalink: /documentation/examples/net/httpserver/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# HTTP server examples: architecture and how they work
This guide explains the HTTP server examples under `./examples/net/http_*` and the supporting standard library modules under `./lib/net/`.
It covers what each example does, how to run it, and how the request handling/CGI pieces are implemented.
## Prerequisites
- Build the project so you have a `fun` executable, or ensure `fun` is on your PATH.
- Typical local builds: `./build_debug/fun` or `./build_release/fun`.
- For examples that serve files/CGI scripts, content is read from `./examples/data/htdocs` by default.
- Helpful env vars used by some examples:
- `FUN_LIB_DIR` — path to the stdlib (`./lib` when running from the repo).
- `FUN_EXEC` — override path to the `fun` interpreter used to run CGI children.
- `FUN_HTDOCS` — override htdocs directory for some examples (not all).
- `FUN_PORT` — override port for some examples (mainly the MT CGI one).
## Supporting stdlib modules (lib/net)
- `net/http_server.fun` — Simple blocking HTTP server class serving static files, with a very small built-in “CGI for .fun files” (spawns `fun` with `QUERY_STRING`/`POST_DATA`).
- `net/http_cgi_server.fun` — Blocking server with fuller CGI support using `net/cgi.fun` to translate CGI output into proper HTTP responses and richer request/header parsing.
- `net/http_cgi_lib_server.fun` — Variant of the CGI server with the same core behavior, explicitly wiring the Fun interpreter path and using `CGI().cgi_to_http_response()` from `net/cgi.fun`.
- `net/cgi.fun` — Helpers to work with CGI-style programs and to translate CGI output (headers + body) into full HTTP/1.1 responses.
See documentation/stdlib.md → net/ for a quick index of these modules.
## Example: http_static_server.fun
- File: `examples/net/http_static_server.fun`
- Purpose: Minimal, hand-written HTTP server that ignores the request path and always responds with a fixed HTML page.
- Key includes: `io/socket.fun`
- Port/backlog: hard-coded `8088`, backlog 10.
- Flow:
- Creates `TcpServer(port, backlog)``listen()` → loop on `accept()`
- `sock_recv()` reads and discards request
- Constructs a literal HTTP/1.1 200 response with `Content-Length` and `Connection: close`
- Sends the response with `sock_send()` and closes the client
- Run:
- `./examples/net/http_static_server.fun`
- Open http://127.0.0.1:8080/
## Example: http_server.fun (static + simple .fun CGI)
- File: `examples/net/http_server.fun`
- Uses: `#include <net/http_server.fun>` (class `HTTPServer`)
- Purpose: Blocking server that serves static files from an htdocs directory; if the requested path ends with `.fun`, it spawns `fun` to run the script and returns its output.
- Defaults in example:
- Port: `8080`
- Htdocs: `./examples/data/htdocs`
- Implementation highlights (see `lib/net/http_server.fun`):
- Parses request line to get `method` and `path`; `/` maps to `/index.html`.
- When path ends with `.fun`, builds a small environment:
- `QUERY_STRING` (for `?a=b`), `POST_DATA` (raw body when `POST`).
- Runs `proc_run("<env> fun <script>")` and uses `out` as response body.
- Otherwise reads the file from `htdocs` and serves it as-is.
- Sends basic HTTP/1.1 headers: 200/404, `Content-Type: text/html`, `Content-Length`, `Connection: close`.
- Run:
- `./examples/net/http_server.fun`
- Open http://127.0.0.1:8080/ and the sample CGI endpoints like `/hello.fun?name=Fun`.
## Example: http_server_cgi.fun (CGI via external interpreter)
- File: `examples/net/http_server_cgi.fun`
- Uses: `#include <net/http_cgi_server.fun>` (class `HTTPCGIServer`)
- Purpose: Blocking server that serves static files and executes `.fun` scripts under htdocs via a child Fun interpreter, with fuller CGI environment and header handling.
- Defaults in example:
- Port: `8080`
- Htdocs: `./examples/data/htdocs`
- Implementation highlights (see `lib/net/http_cgi_server.fun`):
- Robust request-line extraction and header parsing (case-normalized to uppercase).
- Path routing: `/``/index.html`; `.fun` → treat as CGI script.
- Builds CGI env including: `FUN_LIB_DIR`, `REQUEST_METHOD`, `QUERY_STRING`, `SCRIPT_NAME`, `PATH_INFO`, `SERVER_NAME`, `SERVER_PORT`, `SERVER_PROTOCOL`, `HTTP_HOST`, `HTTP_USER_AGENT`, `HTTP_COOKIE`, `CONTENT_TYPE`, `CONTENT_LENGTH`, and `POST_DATA` (if any).
- Interpreter selection priority: `$FUN_EXEC``./build_debug/fun``./build_release/fun``fun` from PATH.
- Uses `net/cgi.fun` to convert CGI output (headers + body) into a proper HTTP/1.1 response before sending.
- Run:
- `./examples/net/http_server_cgi.fun`
- Try: `/`, `/hello.fun?name=Fun`, `/info.fun` under http://127.0.0.1:8080/
## Example: http_server_cgi_lib.fun (CGI via stdlib wrapper)
- File: `examples/net/http_server_cgi_lib.fun`
- Uses: `#include <net/http_cgi_lib_server.fun>` (class `HTTPCGILibServer`)
- Purpose: Same goal as the previous example but split into a slightly different stdlib class; also uses `CGI().cgi_to_http_response()` for translating CGI output.
- Defaults and behavior mirror `HTTPCGIServer`: static files from htdocs, `.fun` as CGI with the same env block and interpreter selection logic.
- Run:
- `./examples/net/http_server_cgi_lib.fun`
- Try: `/`, `/hello.fun?name=Fun`, `/info.fun` under http://127.0.0.1:8080/
## Example: http_mt_server.fun (thread-per-connection)
- File: `examples/net/http_mt_server.fun`
- Uses: `io/socket.fun`, `io/thread.fun`
- Purpose: Hand-written multi-threaded server; main thread blocks in `accept()`, each connection handled in a new Fun thread.
- Behavior: Reads request, replies with a fixed HTML 200 response, then closes the connection.
- Defaults: `PORT = 8080`, `BACKLOG = 128` (note the comment mentions 8089 in a usage line; the code uses 8080).
- Run: `./examples/net/http_mt_server.fun` then open http://127.0.0.1:8080/
## Example: http_mt_server_cgi.fun (thread-per-connection + CGI)
- File: `examples/net/http_mt_server_cgi.fun`
- Uses: `io/socket.fun`, `io/thread.fun`, `net/cgi.fun`
- Purpose: Multi-threaded server that serves static files from htdocs and executes `.fun` scripts as CGI, implemented without higher-level string helpers to keep per-thread globals minimal.
- Defaults: `PORT = 8080`, `BACKLOG = 128`, `HTDOCS = ./examples/data/htdocs`.
- Request handling flow:
- Reads request bytes, extracts the request line, splits out `method` and `target`.
- Splits `path` and `query` on `?`; `/` becomes `/index.html`.
- Parses headers into a map (uppercase keys) and optionally reads a request body.
- Routing:
- If `path` ends with `.fun`: build CGI env; spawn a child `fun` to execute the script; capture stdout; translate to HTTP via `_cgi_to_http_response()`; send back.
- Else: attempt to read the static file from `HTDOCS + path`; send 200 or 404.
- CGI environment variables set (subset):
- `FUN_LIB_DIR`, `REQUEST_METHOD`, `QUERY_STRING`, `SCRIPT_NAME`, `PATH_INFO`, `SERVER_NAME`, `SERVER_PORT`, `SERVER_PROTOCOL`, `HTTP_HOST`, `HTTP_USER_AGENT`, `HTTP_COOKIE`, `CONTENT_TYPE`, `CONTENT_LENGTH`, `POST_DATA` (when present).
- Interpreter selection (similar to CGI examples): `$FUN_EXEC``./build_debug/fun``./build_release/fun``fun` from PATH.
- Notes:
- Allows overriding `HTDOCS` & port via `FUN_HTDOCS` and `FUN_PORT` environment variables.
- Implements its own small helpers (`_trim`, `_ends_with`, `_split_*`) to avoid heavy string utilities inside threads.
- Run: `./examples/net/http_mt_server_cgi.fun` then open http://127.0.0.1:8080/
## Example: http_server_test.fun
- File: `examples/net/http_server_test.fun`
- Purpose: Small test harness to exercise/verify server pieces (implementation details may change). Check the source for exact behavior.
## Common behaviors and notes
- Index handling: most servers map `/` to `/index.html` under the configured `htdocs` directory.
- Static files: served by reading from `<htdocs><path>`; a missing file returns `404 Not Found`.
- CGI scripts:
- Any path ending in `.fun` under `htdocs` is executed with the Fun interpreter as a child process.
- CGI output is expected to be a mix of optional headers and a body; the servers convert this to a valid HTTP/1.1 response (via `net/cgi.fun` or a local helper).
- To ensure the child can `#include` stdlib modules, `FUN_LIB_DIR` is populated (defaults to `./lib` when run from repo root).
- Content types: examples return `Content-Type: text/html; charset=utf-8` by default for dynamic responses; static file content types are not auto-detected in these examples.
- Connection handling: responses include `Connection: close`; examples do not implement keep-alive or HTTP/1.1 request pipelining.
- Security: these are demo servers. Do not expose them to untrusted networks. They lack path normalization, MIME sniffing, directory traversal protection, rate limiting, and TLS.
## How to point htdocs somewhere else
- For class-based servers: call `set_htdocs("/path/to/site")` on the server instance before `start()`.
- For the MT CGI example: set `FUN_HTDOCS=/path/to/site` in the environment before launch.
## Troubleshooting
- If a CGI request yields a 500 and you see “CGI produced no output”, run the target `.fun` directly with your `fun` interpreter and fix any errors.
- Confirm `FUN_LIB_DIR` points to the stdlib (especially when running CGI scripts that `#include` modules).
- If the server cannot start, another process might be using the chosen port.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - objects_basic.fun — overview
subtitle: Documentation for objects_basic.fun — overview
description: Documentation for objects_basic.fun — overview
permalink: /documentation/examples/objects_basic/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# objects_basic.fun — overview
What it shows
- OO basics: defining objects, fields, and invoking methods.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/objects_basic.fun
- Or: fun examples/objects_basic.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - objects_more.fun — overview
subtitle: Documentation for objects_more.fun — overview
description: Documentation for objects_more.fun — overview
permalink: /documentation/examples/objects_more/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# objects_more.fun — overview
What it shows
- Additional object patterns: composition, methods, and utilities.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/objects_more.fun
- Or: fun examples/objects_more.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - os_env.fun — overview
subtitle: Documentation for os_env.fun — overview
description: Documentation for os_env.fun — overview
permalink: /documentation/examples/os_env/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# os_env.fun — overview
What it shows
- Reading and writing environment variables from the operating system.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/os_env.fun
- Or: fun examples/os_env.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - process_example.fun — overview
subtitle: Documentation for process_example.fun — overview
description: Documentation for process_example.fun — overview
permalink: /documentation/examples/process_example/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# process_example.fun — overview
What it shows
- Spawning and capturing subprocess output; simple process management.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/process_example.fun
- Or: fun examples/process_example.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - progress.fun — overview
subtitle: Documentation for progress.fun — overview
description: Documentation for progress.fun — overview
permalink: /documentation/examples/progress/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# progress.fun — overview
What it shows
- Simple progress display in the terminal.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/progress.fun
- Or: fun examples/progress.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - progress_inline.fun — overview
subtitle: Documentation for progress_inline.fun — overview
description: Documentation for progress_inline.fun — overview
permalink: /documentation/examples/progress_inline/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# progress_inline.fun — overview
What it shows
- Inline progress updates (same line updates) for simple terminal UIs.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/progress_inline.fun
- Or: fun examples/progress_inline.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - random_demo.fun — overview
subtitle: Documentation for random_demo.fun — overview
description: Documentation for random_demo.fun — overview
permalink: /documentation/examples/random_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# random_demo.fun — overview
What it shows
- Random number generator usage and seeding basics.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/random_demo.fun
- Or: fun examples/random_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - random_number_example.fun — overview
subtitle: Documentation for random_number_example.fun — overview
description: Documentation for random_number_example.fun — overview
permalink: /documentation/examples/random_number_example/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# random_number_example.fun — overview
What it shows
- Generating random numbers and printing them; small utility demo.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/random_number_example.fun
- Or: fun examples/random_number_example.fun

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - regex_demo.fun — overview
subtitle: Documentation for regex_demo.fun — overview
description: Documentation for regex_demo.fun — overview
permalink: /documentation/examples/regex_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# regex_demo.fun — overview
What it shows
- Regex helpers usage; simple matching and replacement tasks.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/regex_demo.fun
- Or: fun examples/regex_demo.fun
Notes
- Some regex examples depend on the optional PCRE2 extension; enable it in your build to run.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - regex_procedural.fun — overview
subtitle: Documentation for regex_procedural.fun — overview
description: Documentation for regex_procedural.fun — overview
permalink: /documentation/examples/regex_procedural/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# regex_procedural.fun — overview
What it shows
- Procedural approach to regex work: compiling patterns and iterating matches.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/regex_procedural.fun
- Or: fun examples/regex_procedural.fun
Notes
- May require the optional PCRE2 extension in your build.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - rust_hello.fun — overview
subtitle: Documentation for rust_hello.fun — overview
description: Documentation for rust_hello.fun — overview
permalink: /documentation/examples/rust_hello/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# rust_hello.fun — overview
What it shows
- Using Rust opcodes from Fun (when built with Rust support).
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/rust_hello.fun
- Or: fun examples/rust_hello.fun
Notes
- Requires building with FUN_WITH_RUST; otherwise this example will be unavailable.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - rust_hello_args.fun — overview
subtitle: Documentation for rust_hello_args.fun — overview
description: Documentation for rust_hello_args.fun — overview
permalink: /documentation/examples/rust_hello_args/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# rust_hello_args.fun — overview
What it shows
- Passing arguments into Rust-backed opcodes and handling returns.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/rust_hello_args.fun
- Or: fun examples/rust_hello_args.fun
Notes
- Requires building with FUN_WITH_RUST.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - rust_hello_args_return.fun — overview
subtitle: Documentation for rust_hello_args_return.fun — overview
description: Documentation for rust_hello_args_return.fun — overview
permalink: /documentation/examples/rust_hello_args_return/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# rust_hello_args_return.fun — overview
What it shows
- Demonstrates returning values from Rust-backed opcodes with arguments.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/rust_hello_args_return.fun
- Or: fun examples/rust_hello_args_return.fun
Notes
- Requires building with FUN_WITH_RUST.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - serial_demo.fun — overview
subtitle: Documentation for serial_demo.fun — overview
description: Documentation for serial_demo.fun — overview
permalink: /documentation/examples/serial_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# serial_demo.fun — overview
What it shows
- Serial port access and basic read/write (when available on your system).
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/serial_demo.fun
- Or: fun examples/serial_demo.fun
Notes
- Requires serial device access; may depend on platform support and permissions.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - short_circuit_test.fun — overview
subtitle: Documentation for short_circuit_test.fun — overview
description: Documentation for short_circuit_test.fun — overview
permalink: /documentation/examples/short_circuit_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# short_circuit_test.fun — overview
What it shows
- Boolean evaluation order and short-circuit behavior with && and ||.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/short_circuit_test.fun
- Or: fun examples/short_circuit_test.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - signed_ints.fun — overview
subtitle: Documentation for signed_ints.fun — overview
description: Documentation for signed_ints.fun — overview
permalink: /documentation/examples/signed_ints/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# signed_ints.fun — overview
What it shows
- Signed integer types and operations; ranges and conversions.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/signed_ints.fun
- Or: fun examples/signed_ints.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - stdlib_showcase.fun — overview
subtitle: Documentation for stdlib_showcase.fun — overview
description: Documentation for stdlib_showcase.fun — overview
permalink: /documentation/examples/stdlib_showcase/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# stdlib_showcase.fun — overview
What it shows
- Sampler of common standard library modules and utilities.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/stdlib_showcase.fun
- Or: fun examples/stdlib_showcase.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - strings_test.fun — overview
subtitle: Documentation for strings_test.fun — overview
description: Documentation for strings_test.fun — overview
permalink: /documentation/examples/strings_test/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# strings_test.fun — overview
What it shows
- String helpers and edge cases; splitting, joining, trimming, and formatting.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/strings_test.fun
- Or: fun examples/strings_test.fun

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - tcp_http_get.fun — overview
subtitle: Documentation for tcp_http_get.fun — overview
description: Documentation for tcp_http_get.fun — overview
permalink: /documentation/examples/tcp_http_get/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# tcp_http_get.fun — overview
What it shows
- Manual HTTP client over raw TCP sockets: connect, write request, read response.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/tcp_http_get.fun
- Or: fun examples/tcp_http_get.fun
Notes
- Requires network access to the target host used in the script.

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - tcp_http_get_class.fun — overview
subtitle: Documentation for tcp_http_get_class.fun — overview
description: Documentation for tcp_http_get_class.fun — overview
permalink: /documentation/examples/tcp_http_get_class/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# tcp_http_get_class.fun — overview
What it shows
- Manual HTTP client implemented with a small helper class over sockets.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/tcp_http_get_class.fun
- Or: fun examples/tcp_http_get_class.fun
Notes
- Requires network access to the target host used in the script.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_bits.fun — overview
subtitle: Documentation for test_bits.fun — overview
description: Documentation for test_bits.fun — overview
permalink: /documentation/examples/test_bits/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_bits.fun — overview
What it shows
- Bitwise utilities demonstration (and/or/xor/shifts) and small tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_bits.fun
- Or: fun examples/test_bits.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_dec_to_hex.fun — overview
subtitle: Documentation for test_dec_to_hex.fun — overview
description: Documentation for test_dec_to_hex.fun — overview
permalink: /documentation/examples/test_dec_to_hex/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_dec_to_hex.fun — overview
What it shows
- Decimal to hexadecimal conversion helper/tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_dec_to_hex.fun
- Or: fun examples/test_dec_to_hex.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_hex_to_dec.fun — overview
subtitle: Documentation for test_hex_to_dec.fun — overview
description: Documentation for test_hex_to_dec.fun — overview
permalink: /documentation/examples/test_hex_to_dec/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_hex_to_dec.fun — overview
What it shows
- Hexadecimal to decimal conversion helper/tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_hex_to_dec.fun
- Or: fun examples/test_hex_to_dec.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_include.fun — overview
subtitle: Documentation for test_include.fun — overview
description: Documentation for test_include.fun — overview
permalink: /documentation/examples/test_include/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_include.fun — overview
What it shows
- Small include mechanics test; ensures local and stdlib includes work.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_include.fun
- Or: fun examples/test_include.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_rol.fun — overview
subtitle: Documentation for test_rol.fun — overview
description: Documentation for test_rol.fun — overview
permalink: /documentation/examples/test_rol/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_rol.fun — overview
What it shows
- Bit rotation (ROL) helper/tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_rol.fun
- Or: fun examples/test_rol.fun

View file

@ -0,0 +1,38 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_serial.fun — overview
subtitle: Documentation for test_serial.fun — overview
description: Documentation for test_serial.fun — overview
permalink: /documentation/examples/test_serial/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_serial.fun — overview
What it shows
- Serial port test; opens a port and exchanges a few bytes (when available).
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_serial.fun
- Or: fun examples/test_serial.fun
Notes
- Requires serial device access; may depend on platform support and permissions.

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_shl.fun — overview
subtitle: Documentation for test_shl.fun — overview
description: Documentation for test_shl.fun — overview
permalink: /documentation/examples/test_shl/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_shl.fun — overview
What it shows
- Bit shift left (SHL) helper/tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_shl.fun
- Or: fun examples/test_shl.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_types.fun — overview
subtitle: Documentation for test_types.fun — overview
description: Documentation for test_types.fun — overview
permalink: /documentation/examples/test_types/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_types.fun — overview
What it shows
- Type checks and simple assertions around type behavior.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_types.fun
- Or: fun examples/test_types.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - test_xor.fun — overview
subtitle: Documentation for test_xor.fun — overview
description: Documentation for test_xor.fun — overview
permalink: /documentation/examples/test_xor/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# test_xor.fun — overview
What it shows
- Bitwise XOR helper/tests.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/test_xor.fun
- Or: fun examples/test_xor.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - thread_class_example.fun — overview
subtitle: Documentation for thread_class_example.fun — overview
description: Documentation for thread_class_example.fun — overview
permalink: /documentation/examples/thread_class_example/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# thread_class_example.fun — overview
What it shows
- Threading building blocks using a small thread class; start/join patterns.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/thread_class_example.fun
- Or: fun examples/thread_class_example.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - threads_demo.fun — overview
subtitle: Documentation for threads_demo.fun — overview
description: Documentation for threads_demo.fun — overview
permalink: /documentation/examples/threads_demo/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# threads_demo.fun — overview
What it shows
- Threading building blocks and concurrent execution demo.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/threads_demo.fun
- Or: fun examples/threads_demo.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - try_catch_finally.fun — overview
subtitle: Documentation for try_catch_finally.fun — overview
description: Documentation for try_catch_finally.fun — overview
permalink: /documentation/examples/try_catch_finally/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# try_catch_finally.fun — overview
What it shows
- Structured error handling with try/catch/finally blocks.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/try_catch_finally.fun
- Or: fun examples/try_catch_finally.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - type_safety.fun — overview
subtitle: Documentation for type_safety.fun — overview
description: Documentation for type_safety.fun — overview
permalink: /documentation/examples/type_safety/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# type_safety.fun — overview
What it shows
- Static/dynamic type checks and enforcing type safety in small examples.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/type_safety.fun
- Or: fun examples/type_safety.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - type_safety_fails.fun — overview
subtitle: Documentation for type_safety_fails.fun — overview
description: Documentation for type_safety_fails.fun — overview
permalink: /documentation/examples/type_safety_fails/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# type_safety_fails.fun — overview
What it shows
- Examples that intentionally violate type expectations to illustrate safety checks.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/type_safety_fails.fun
- Or: fun examples/type_safety_fails.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - typeof.fun — overview
subtitle: Documentation for typeof.fun — overview
description: Documentation for typeof.fun — overview
permalink: /documentation/examples/typeof/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# typeof.fun — overview
What it shows
- Type inspection using typeof and related helpers.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/typeof.fun
- Or: fun examples/typeof.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - typeof_features.fun — overview
subtitle: Documentation for typeof_features.fun — overview
description: Documentation for typeof_features.fun — overview
permalink: /documentation/examples/typeof_features/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# typeof_features.fun — overview
What it shows
- A tour of typeof-related features and type introspection helpers.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/typeof_features.fun
- Or: fun examples/typeof_features.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - types_integers.fun — overview
subtitle: Documentation for types_integers.fun — overview
description: Documentation for types_integers.fun — overview
permalink: /documentation/examples/types_integers/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# types_integers.fun — overview
What it shows
- Integer type families, ranges, and basic operations.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/types_integers.fun
- Or: fun examples/types_integers.fun

View file

@ -0,0 +1,35 @@
---
layout: page
published: true
noToc: true
noComments: false
noDate: false
title: Fun - types_overview.fun — overview
subtitle: Documentation for types_overview.fun — overview
description: Documentation for types_overview.fun — overview
permalink: /documentation/examples/types_overview/
lang: en
tags:
- documentation
- handbook
- installation
- usage
- introduction
- help
- guide
- howto
- docs
- specifications
- specs
- repl
---
# types_overview.fun — overview
What it shows
- Overview of language types with small examples.
How to run
- export FUN_LIB_DIR="./lib"
- ./build_debug/fun examples/types_overview.fun
- Or: fun examples/types_overview.fun

Some files were not shown because too many files have changed in this diff Show more