328 Commits

Author SHA1 Message Date
d29afd5884 Add standard library reference manual with per-module API docs
Create docs/manual/stdlib/ with 12 topic pages covering all stdlib
modules (builtins, Option/Result, collections, iterators, math,
strings, ranges, async runtime, networking, time, synchronization).
Move scattered stdlib content from language manual pages into the
dedicated stdlib section, replacing with concise summaries and links.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 19:13:31 +02:00
04edece055 Split language manual into topic pages with cross-references
Break docs/manual.md (3074 lines) into 14 focused topic pages under
docs/manual/, add inter-page cross-references, and remove duplicated
sections (? operator, iterator protocols, unsafe blocks examples).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 18:36:08 +02:00
fe6263d575 Stream CLI run output incrementally 2026-04-04 17:58:57 +02:00
46ba82bc55 Commit remaining unstaged changes 2026-04-04 15:47:15 +02:00
fb0c2078cd Fix codegen operator dispatch and specialization regressions 2026-04-04 15:45:42 +02:00
b6969c9a1b Document assignment operator void return requirement in manual
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:42:19 +02:00
e9c66e8cfc Enforce void return for assignment operators and fix recursive generic types
Typechecker:
- Assignment operators (+=, -=, *=, /=, []=, etc.) must now return void.
  Non-assignment operators still require a return type. This matches
  Rust and Python semantics where compound assignment is a statement,
  not an expression.
- Fix unspecializedGenericTemplate rejecting recursive generic types
  like Option[DequeNode[T]] inside DequeNode[T]. Generic-kind bindings
  from enclosing scope are now treated as concrete.

Codegen:
- ArrayIndexAssign and PointerIndexAssign magic builtins emit plain
  assignments instead of comma expressions when return type is void.
- Fix anonymous ref symbol resolution for monomorphized types in
  lowerIndirectBaseType (stale anon_ref -> named ref on the fly).

Stdlib:
- All compound assignment operators (+=, -=, *=, /=, string +=) and
  all []= operators (array, seq, UncheckedArray, deque) now return void.

Tests:
- Updated operator definitions in c_codegen, codegen, and
  monomorphization test preludes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:27:11 +02:00
fc413c4129 Add deque[T], FIFOQueue/LIFOQueue, and fix anonymous ref codegen
Stdlib:
- Add deque[T] backed by a ring buffer over Buffer[T] with O(1)
  amortized push/pop at both ends, O(1) indexing, and proper
  ownership transfer via move on pop
- Rename FIFOQueue to LIFOQueue (seq-backed, LIFO semantics)
- Add FIFOQueue backed by deque[T] for true FIFO with O(1) pop
- Refactor Buffer API: initBufferStorage -> init, bufferReserve ->
  reserve with method-style calls
- Add async_queues.pn example with FIFO ordering, producer/consumer,
  bounded back-pressure, and fan-in tests

Codegen fix:
- Fix anonymous ref type symbols being emitted for named ref types
  when monomorphization creates new type objects with different IDs.
  lowerIndirectBaseType now detects stale anonymous ref symbols and
  resolves them to their named equivalents on the fly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 12:48:29 +02:00
889a14731c Add default parameter values, fix relative imports, and add WaitQueue deque ops
Parser:
- Fix parseGenericConstraint to recognize '=' as a stop token, enabling
  fn foo(x: int64 = 0) syntax
- Fix parseModulePath and parseImportPath to handle '../' as a single
  token (the lexer greedily merges '..' and '/')

Typechecker:
- Relax isCapable to accept fewer arguments when trailing parameters
  have defaults
- Fill in default values for missing arguments in lowerResolvedCall

C runtime:
- Add peon_wait_queue_pop_back and peon_wait_queue_wake_last for O(1)
  tail removal, making WaitQueue a proper deque
- Rename wake_one -> wake_first for symmetry with wake_last

Stdlib:
- Move sync.pn into sync/ directory (events.pn, queues.pn)
- Fix Event.set() missing self.signaled = true assignment (deadlock bug)
- Add wakeLast and isEmpty bindings for WaitQueue
- Fix WaitQueue clone to use UFCS init() style

Syntax highlighting:
- Fix import path regex to support multiple ../ prefixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:44:24 +02:00
f8cf38b443 Extract shared C preamble into a generated header file
Every compiled module .c file was getting an identical ~200-line preamble
with all type definitions, forward declarations, and function signatures
inlined. This extracts the preamble into a single peon_preamble.h that
each module #includes, reducing generated LOC by ~70% (13k -> 4k for
the sequences example).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 01:16:57 +02:00
f15d199e6d Fix backend enum lowering and borrow parsing 2026-04-03 18:41:53 +02:00
1139c024ae Rewrite C runtime section and fix stale __check_ref references
Replace the outdated Section 10 with an accurate description of the
generational reference management model (not refcounting), the split
runtime source files, and the full async/networking/closure/trace
infrastructure. Update PeonGenerator struct to include inline frames
and trace support. Replace all __check_ref references with the actual
peon_open_ref/peon_check_ref/peon_deref naming.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:40:40 +02:00
3538e8be0d Update architecture, review, and manual docs for recent changes
Reflect the significant refactoring since the last doc updates:
architecture-review.md now annotates each finding with fix status
(magics.nim, parser semantic extraction, isInterfaceType helper,
format-string lowering move, codegen dedup, Iterable magic pragma).
architecture.md adds suspension normalization pass, tuple/void/value-enum
types, greedy operator lexing, pragma constructors, var/lent unification,
generic binary operators, and borrow-aware iterator interfaces.
manual.md replaces the old MutIterator/mnext protocol with the new
BorrowIterator/MutBorrowIterator hierarchy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 18:09:14 +02:00
265e2b782f Remove stale note from the README 2026-04-03 17:46:10 +02:00
e007ca526c Redesign iterator borrow interfaces 2026-04-03 17:06:10 +02:00
21b244cf33 Defer generic type-witness call resolution 2026-04-03 11:55:56 +02:00
67bde6aaf2 Fix native stack traces and hook specialization lookup 2026-04-03 11:18:09 +02:00
5cb083d115 Update async model documentation 2026-04-03 00:46:53 +02:00
05d6157de4 Implement value enums and refresh net docs 2026-04-02 22:24:34 +02:00
19b90729a9 Add first-class void type support 2026-04-02 16:54:23 +02:00
adedad48e9 Add monomorphization support for generic binary operators
The monomorphizer had no handler for TypedBinaryExpr, so generic
user-defined operators like `..` were never specialized. Added a
genericArgs field to TypedBinaryExpr, stored the resolved generic
args during typechecking, and added a monomorphizer handler that
requests function specialization for generic binary operators.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:54:49 +02:00
82163d36c4 Route user-defined binary operators through function calls in C backend
The C backend previously tried to lower every binary operator as inline
C via a hardcoded operator table, which failed for user-defined operators
like `..` and `**`. Now TypedBinaryExpr carries the resolved operator
function from the typechecker, and the C backend emits a proper function
call for non-builtin operators while keeping inline C for builtins.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:22:30 +02:00
178e9353f7 Add structured concurrency example 2026-04-02 14:58:44 +02:00
6c163e1690 Replace symbol-table longest-match with greedy operator lexing
The lexer previously relied on a fixed symbol table to tokenize
operators, which meant user-defined operators like ** and .. could
not be lexed as single tokens. Now the lexer greedily consumes
contiguous runs of operator-class characters, with special handling
for . (Dot when alone, Symbol when part of a multi-char operator)
and a lookahead fix in parseNumber to avoid consuming . as a decimal
point when followed by another dot (e.g. 1..5).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:36:48 +02:00
ea7a9b936f Prepare stdlib and typing for async generators 2026-04-02 14:15:02 +02:00
fbf1b51e46 Add blocking async offload and resolver support 2026-04-02 13:09:16 +02:00
5ea4edc576 Avoid deep-copying compiler types 2026-04-02 13:05:11 +02:00
faa2046831 Support nested yield normalization 2026-04-01 20:10:03 +02:00
72f16f4396 Add suspension normalization for nested await lowering 2026-04-01 19:48:45 +02:00
07757019d8 Add repeated runAsync regressions 2026-04-01 19:09:34 +02:00
88d5fb71cc Implement async time, shielding, and socket foundations 2026-04-01 19:04:58 +02:00
d2eca99769 Refactor iteration protocols 2026-04-01 16:09:37 +02:00
18ef2bb751 Add needsDestroy and reject invalid destroy calls 2026-04-01 15:23:05 +02:00
7ea7b6716e Tighten C interop manual details 2026-04-01 14:58:21 +02:00
96f23890d8 Clarify importc pragma placement in manual 2026-04-01 14:54:16 +02:00
de22cfd07f Document importc const interop rules 2026-04-01 14:51:55 +02:00
859da13d57 Add importc const support and fix cpuTime 2026-04-01 14:50:04 +02:00
524318d98a Document pragma constructors 2026-04-01 14:16:37 +02:00
93f7146c58 Add pragma constructors 2026-04-01 14:12:20 +02:00
015156362a Stream REPL output from the latest evaluation 2026-04-01 13:48:12 +02:00
f72079dd98 Fix finite constrained generic runtime storage 2026-04-01 13:31:30 +02:00
09fa147e16 Allow regular calls to forward existing mutable borrows 2026-04-01 13:22:31 +02:00
ff3425338d Split async runtime support and add native suspension primitives 2026-04-01 13:07:48 +02:00
d14173fdce docs: tighten manual interface and for-loop notes 2026-04-01 01:45:52 +02:00
0a3c26c534 Add anonymous tuple types 2026-04-01 01:39:45 +02:00
e641283991 Move spawn type syntax rejection out of parser 2026-04-01 01:28:13 +02:00
d9b4b148ee Reject tuple exportc declarations 2026-04-01 01:21:17 +02:00
4c08c91140 Move format string and pragma parsing cleanup out of parser 2026-04-01 01:18:24 +02:00
c03d3b37cd Move parser semantic checks into type checking 2026-04-01 01:01:27 +02:00
72125b2a63 Deduplicate C codegen helpers 2026-04-01 00:18:42 +02:00