diff --git a/site/public/pkg/nue_wasm.d.ts b/site/public/pkg/nue_wasm.d.ts index 3122391..619fdca 100644 --- a/site/public/pkg/nue_wasm.d.ts +++ b/site/public/pkg/nue_wasm.d.ts @@ -9,8 +9,8 @@ export function format_playground(source: string): any; /** * Runs one Nue source file in the browser-friendly playground pipeline. * - * This function is the wasm bridge used by `web/main.js`. It returns a plain - * JavaScript object so the frontend can render status, diagnostics, and + * This function is the wasm bridge for the web playground runtime. It returns a + * plain JavaScript object so the frontend can render status, diagnostics, and * emitted runtime events without any backend service. */ export function run_playground(source: string, timeout_ms?: number | null, max_steps?: number | null, max_output_lines?: number | null, max_memory_bytes?: number | null): any; diff --git a/site/public/pkg/nue_wasm.js b/site/public/pkg/nue_wasm.js index c2dce39..8f9067f 100644 --- a/site/public/pkg/nue_wasm.js +++ b/site/public/pkg/nue_wasm.js @@ -15,8 +15,8 @@ export function format_playground(source) { /** * Runs one Nue source file in the browser-friendly playground pipeline. * - * This function is the wasm bridge used by `web/main.js`. It returns a plain - * JavaScript object so the frontend can render status, diagnostics, and + * This function is the wasm bridge for the web playground runtime. It returns a + * plain JavaScript object so the frontend can render status, diagnostics, and * emitted runtime events without any backend service. * @param {string} source * @param {number | null} [timeout_ms] diff --git a/site/public/pkg/nue_wasm_bg.wasm b/site/public/pkg/nue_wasm_bg.wasm index d254473..40cc476 100644 Binary files a/site/public/pkg/nue_wasm_bg.wasm and b/site/public/pkg/nue_wasm_bg.wasm differ diff --git a/site/src/components/NuePlaygroundIsland.tsx b/site/src/components/NuePlaygroundIsland.tsx index 39c737f..f0806d6 100644 --- a/site/src/components/NuePlaygroundIsland.tsx +++ b/site/src/components/NuePlaygroundIsland.tsx @@ -142,6 +142,49 @@ def main() -> Int32 do assert! policy3.budget_ms() == 180 0 end +`, + }, + { + id: "record_keyword_args", + label: "Record + Keyword Args", + source: `# Record defaults and keyword arguments for the final parameter. +# This keeps options-style APIs explicit and concise. +from std::io import puts + +struct RuntimeOptions do + timeout_ms: Int32 + retry: Int32 + verbose: Bool +end + +def run_with_options( + base: Int32, + own opt: { timeout_ms: Int32 = 30, retry: Int32 = 3, verbose: Bool = false }, +) -> Int32 do + typed = RuntimeOptions{ ...move opt } + bonus: Int32 = 0 + if typed.verbose then + set bonus = 100 + end + base + typed.timeout_ms + typed.retry + bonus +end + +def main() -> Int32 do + # Keyword arguments are sugar for constructing the final record argument. + score1 = run_with_options(1, timeout_ms: 10) + score2 = run_with_options(1, timeout_ms: 10, retry: 1) + score3 = run_with_options(1, retry: 2, verbose: true) + assert! score1 == 14 + assert! score2 == 12 + assert! score3 == 133 + puts("keyword sugar => 14, 12, 133") + + # Explicit record literal form remains available. + score4 = run_with_options(1, { timeout_ms: 20, retry: 1, verbose: false }) + assert! score4 == 22 + puts("explicit record => 22") + 0 +end `, }, ]; diff --git a/site/src/sections/features.mdx b/site/src/sections/features.mdx index 6a05ef3..8459c99 100644 --- a/site/src/sections/features.mdx +++ b/site/src/sections/features.mdx @@ -4,6 +4,7 @@ - Trailing blocks for clearer syntax, including non-local returns and `break`/`continue`. - Guard-first control flow `guard` with explicit early-exit rules. - Uniformed function call syntax (UFCS) for method-style calls on any value. +- Keyword arguments make options-style calls concise without implicit conversions. - Function overloading enables multiple dispatch, while protocols provide localized resolution. - Predictable type inference, no implicit conversions. - Ownership and explicit transfer with `move` and `copy`. @@ -12,6 +13,7 @@ - Non-storable view types prevent accidental long-lived borrows: `ref`, `str`, and `slice`. - `defer` statement for deterministic resource management. - Algebraic data types (ADTs) with first-class support for `enum` and `struct`. +- First-class record types with closed structural shape and strict field-based identity. - Pattern matching with exhaustive checks and irrefutable patterns. - Generics and protocols with associated types keep abstractions precise. - Opaque return types with `some`, preserving static dispatch.