Core Runtime (.lcore files)
Luma ships with a small core runtime, implemented directly in Go, that provides the low-level building blocks used by the language. These functions are not written in Luma itself, but included into compiled programs on demand based on what features each program actually uses.
What are core functions?
- They are Go functions prefixed with
_luma_(e.g._luma_toInt,_luma_list_add_all_bool). - They handle essentials like type conversions, optional handling, list/set/map operations, printing, introspection, etc.
- They form the “standard library kernel” on which higher-level Luma features depend.
File format and extension
- Core functions are stored in
.lcorefiles in thecore/directory. .lcoreis chosen to clearly distinguish runtime source from user.lumaprograms and from regular.gofiles.- Each
.lcorefile contains one or more Go functions, usually grouped by topic.
Example:
// Name: _luma_list_add_all_bool
// Description: Appends all elements from a bool slice to the target bool list.
// Author: Luma Core
// Version: 1.0
func _luma_list_add_all_bool(list *[]bool, values []bool) {
*list = append(*list, values...)
}Sliced core library
The core runtime is not embedded as a single monolithic blob. Instead, coregen splits .lcore files into 19 feature slices based on filename prefix. Only the slices a program actually uses are included in the generated Go output.
| Slice constant | Filename prefix | What it provides |
|---|---|---|
CorePrint |
_luma_print, _luma_show, _luma_sprint |
Printing and string display |
CoreConvert |
_luma_to, _luma_type, _luma_is_type |
Type conversions and introspection |
CorePtrBox |
_luma_ptr_ |
Optional value boxing/unboxing |
CoreList |
_luma_list_ |
List operations (add, sort, filter, etc.) |
CoreSet |
_luma_set_ |
Set operations (add, contains, union, etc.) |
CoreStringOps |
_luma_string_ |
String helpers (chars, index_of, etc.) |
CoreFile |
_luma_file, _luma_glob |
File I/O and glob matching |
CoreCli |
_luma_cli |
CLI argument parsing and prompts |
CoreDateTime |
_luma_date, _luma_datetime, _luma_time |
Date, time, and datetime operations |
CoreBit |
_luma_bit_ |
Bitwise operations |
CoreBytes |
_luma_bytes_, _luma_byte_to_, _luma_int_to_ |
Byte array operations |
CoreJson |
_luma_json |
JSON encode/decode |
CoreServer |
_luma_server, _luma_get, _luma_post, … |
HTTP server routes |
CoreBuffer |
_luma_buffer |
String buffer operations |
CoreCrypto |
_luma_crypto |
Hashing and cryptographic functions |
CoreEncoding |
_luma_encoding, _luma_hex, _luma_base64 |
Hex and base64 encoding |
CoreTcp |
_luma_tcp |
TCP client/server |
CoreDb |
_luma_db |
Database operations |
CoreEnv |
_luma_env |
Environment variable access |
This means a simple print("Hello") program only includes CorePrint (~3 functions), not the entire runtime.
How they are included in compilation
- The generator tool
coregenreads all.lcorefiles from thecore/directory and groups them by filename prefix into feature slices. - It generates
core_gen.go(at the project root) containing oneCore*string constant per slice. - During compilation, the compiler tracks which core slices are needed as it generates code (see Compilation Pipeline for details).
- Only the needed
Core*constants are emitted into the generated Go program. - Developers can set the
LUMA_CORE=devenvironment variable to pull.lcorefiles directly from disk during compiler development.
Regenerating core_gen.go
After modifying any .lcore file, regenerate the embedded constants:
cd cmd/coregen && go run main.goThis reads all files from core/ and writes the updated core_gen.go to the project root.
Why not .go?
.lcorefiles are not standalone Go packages:- they don’t declare
package, - they don’t import dependencies,
- they are meant to be pasted into the generated
mainpackage.
- they don’t declare
- Using
.gowould mislead tools likego buildor editors. .lumais reserved for user code..lcoremakes their purpose explicit: Luma core runtime.
Development guidelines
- Functions must start with
_luma_to avoid colliding with user code. - Keep them minimal and consistent; they are the trusted runtime.
- Document parameters and return types in comments (helps both maintainers and the generator).
- Naming determines slicing: the filename prefix of a
.lcorefile determines whichCore*slice it belongs to. When adding a new.lcorefile, use the correct prefix (e.g._luma_list_*.lcorefor list operations) socoregenroutes it to the right slice. - When core changes are made, regenerate
core_gen.gowithcd cmd/coregen && go run main.goand commit it.