bare func declaration identities (comptime)

This commit is contained in:
2026-07-18 14:05:55 +02:00
parent 85693e57e1
commit e889a99e55
8 changed files with 512 additions and 74 deletions
+10 -4
View File
@@ -144,15 +144,20 @@ call_mapper func(mapper native.Imported_Mapper) c_int {
}
```
Native Brolang function pointer values use `*func(...) R`, with fallible
Native Brolang function pointer values use `@func(...) R`, with fallible
channels written on the result:
```bro
call func(callback *func(value i32) i32, value i32) i32 {
call func(callback @func(value i32) i32, value i32) i32 {
return callback(value)
}
```
Bare `func(...) R` and `c_func(...) R` values are comptime-only declaration
identities. They implicitly materialize compatible pointers in runtime pointer
contexts; pointers do not convert back to bare identities. Aggregates containing
bare identities are likewise comptime-only.
Bodyless manual and imported C functions may be variadic:
```bro
@@ -226,11 +231,12 @@ Current prototype features:
- Plain imported C structs/unions, fixed arrays, and C function pointer typedefs, including keyed literals, field access, callbacks, and Apple Silicon by-value ABI lowering
- Qualified imported globals and functions with package-aware symbol mangling
- Demand-monomorphized Brolang and C-ABI functions
- Recursively stable comptime values—including booleans, integers, floats, types, immutable bytes, enums, fixed arrays, records/tuples, optionals, tagged unions, and concrete function values—may be interleaved with runtime parameters, are erased from the ABI, and specialize from explicit arguments, declaration identity, or exact inference provenance
- Recursively stable comptime values—including booleans, integers, floats, types, immutable bytes, enums, fixed arrays, records/tuples, optionals, tagged unions, and bare function identities—may be interleaved with runtime parameters, are erased from the ABI, and specialize from explicit arguments, declaration identity, or exact inference provenance
- Forced typed comptime expressions (`$sum(1, 2)`, `$Point { x = 1, y = 2 }`) and comptime value blocks (`${ yield 4 }`)
- Zig-style comptime type factories returning anonymous native structs (`Box func($T type) type`, used as `Box(i32)`)
- Comptime execution for bodyful Brolang functions with mutable locals, loops, `defer`/`errdefer`, `match`, `try`/`catch`, pointer/slice storage mutation, pointer captures, and calls through comptime-known function values
- Native function pointer values and types (`*func(...) R`, `*func(...) R ! E`, `?*func(...) R`)
- Comptime-only native and C function identities (`func(...) R`, `c_func(...) R`) with structural comptime-only propagation through aggregates
- Native function pointer values and types (`@func(...) R`, `@func(...) R ! E`, `?@func(...) R`) with implicit bare-to-pointer materialization
- Typed allocation/reallocation through `std/mem` and generic dynamic arrays through `std/arraylist`
- Bodyless concrete C function declarations with exact external symbol names
- Bodyless manual and imported C variadic declarations with default argument promotions