Update series syntax and binder scope handling
Refine the BNF for `series` to explicitly include the `lookback_limit` and `schema`. Introduce scope management within the `bind` function for `if/else` branches to ensure correct context handling during compilation. Add `Again` and `GetField` node kinds to the `Specializer`. Improve lexer to ignore invisible characters within identifiers, demonstrated by a new test case.
This commit is contained in:
+2
-1
@@ -92,7 +92,8 @@ This document defines the syntax (BNF) and semantics of the Myc language, a Lisp
|
||||
- **Vectors (Tuples):** Enclosed in square brackets `[1 2 3]`. Evaluates to a vector/tuple structure.
|
||||
- **Records:** Enclosed in curly braces with keyword keys and any expression as values `{:id 101 :name "Alice"}`. They provide O(1) field access using internal memory layouts. Structural equality `(= {:a 1} {:a 1})` is `true`.
|
||||
- **Series:** A core concept for financial analysis. Series are "infinite" queues with a maximum length (lookback).
|
||||
- They are created via the `(series ...)` function specifying a record layout (e.g., `(series {:price :float :volume :int})`).
|
||||
- They are created via the `(series lookback_limit schema)` function. The `schema` can be a record layout (e.g., `{:price :float}`) or a type keyword (e.g., `:float`).
|
||||
- Example: `(series 100 {:price :float :volume :int})`.
|
||||
- **Indexing:** You access items in a series by calling it or an extracted field like a function with an integer index: `(my_series 0)`. **Crucially, index `0` represents the most recently pushed item.** Index `1` is the second most recent, and so on (lookback indexing).
|
||||
|
||||
## 4. Special Forms and Evaluation logic
|
||||
|
||||
Reference in New Issue
Block a user