-
Notifications
You must be signed in to change notification settings - Fork 0
Examples Cookbook
HuyHAP edited this page Mar 20, 2026
·
4 revisions
This guide walks through the example and regression files in tests/regression/, explains what each one demonstrates, and shows the fastest command to run it.
- Read First Programs first.
| File | Main topic |
|---|---|
01_web_fetcher_thread.lp |
HTTP + threads + SQLite |
02_oop_game_engine.lp |
classes, inheritance, methods |
03_memory_arena.lp |
manual arena allocation |
04_parallel_for.lp |
parallel for syntax |
05_system_sqlite.lp |
platform + SQLite |
test_global_multiline_lambda.lp |
top-level multiline lambda |
test_inheritance_access.lp |
protected inheritance rules |
test_json.lp |
JSON round-trip |
test_memory_control.lp |
arena and pool helpers |
test_multiline_lambda.lp |
local multiline lambda |
test_string_operations.lp |
string methods |
test_thread_sqlite.lp |
thread join + nested subscript + SQLite |
test_type_inference.lp |
local type inference |
http.get(...)thread.spawn(...)thread.join(...)- SQLite writes from worker threads
lp tests/regression/01_web_fetcher_thread.lp- each worker is a named function
- each worker returns
int - the main thread validates
thread.join(...)results
- class fields
- inherited movement logic
- subclass-specific behavior
- method calls on objects
lp tests/regression/02_oop_game_engine.lp- both
PlayerandEnemyinherit fromEntity - methods mutate object fields directly through
self
memory.arena_new(...)memory.arena_alloc(...)memory.cast(...)- explicit arena cleanup
lp tests/regression/03_memory_arena.lp- memory is managed explicitly
- cleanup is part of the example, not optional decoration
- the
parallel forsyntax - numeric range iteration for heavy work
- current reduction caveats
lp tests/regression/04_parallel_for.lp- the example uses
math.sin(...)andmath.cos(...) - the code comments already warn that reductions are not automatic
platform.os()platform.arch()platform.cores()- SQLite table creation and querying
lp tests/regression/05_system_sqlite.lp- platform helpers return runtime values that are easy to print with
str(...) - SQLite query results are accessed through nested subscript
- top-level multiline lambda assignment
lp test examples-
protectedfield access from a subclass -
protectedmethod access from a subclass - override behavior
lp test examplesjson.loads(...)json.dumps(...)- indexed access into parsed JSON values
lp test examples- arena allocation
- pool allocation
-
memory.cast(...)on both allocation paths
lp test examples- multiline lambda inside local scope
lp test examples-
strip,lower,upper -
find,count -
split,join -
startswith,endswith,isdigit
lp test examples- thread return values through
join - SQLite use from multiple workers
- nested subscript access like
rows[0]["n"]
lp test examples- inferred
intandstr - inferred value flow into another function call
lp test examples- Some examples require network access, especially
01_web_fetcher_thread.lp. - SQLite examples create local
.dbfiles as part of normal execution. -
parallel forsyntax is demonstrated in the examples, but actual parallel speedup still depends on toolchain configuration.
Back to Home | GitHub Repo | Issues
- Home
- Installation and Setup
- First Programs
- Language Basics
- Quick Reference
- Troubleshooting
- Known Limitations
- Language Reference
- Expressions and Collections
- Object-Oriented Programming
- Error Handling
- Feature Overview
- Feature Status
- Runtime Modules
- Concurrency and Parallelism
- Parallel and GPU Computing
- Security Overview
- Security Reference
- Security Calling Patterns
- Native ASM is the default backend.
- On Windows, prefer
--gccfor verification. - Docs are written against verified current behavior.