Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions site/public/pkg/nue_wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions site/public/pkg/nue_wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Binary file modified site/public/pkg/nue_wasm_bg.wasm
Binary file not shown.
43 changes: 43 additions & 0 deletions site/src/components/NuePlaygroundIsland.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
`,
},
];
Expand Down
2 changes: 2 additions & 0 deletions site/src/sections/features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- <span class="em1">Trailing blocks</span> for clearer syntax, including <span class="em1">non-local returns</span> and `break`/`continue`.
- Guard-first control flow `guard` with <span class="em1">explicit early-exit</span> rules.
- <span class="em1">Uniformed function call syntax</span> (UFCS) for method-style calls on any value.
- <span class="em1">Keyword arguments</span> make options-style calls concise without implicit conversions.
- Function overloading enables <span class="em1">multiple dispatch</span>, while protocols provide localized resolution.
- Predictable type inference, <span class="em2">no implicit conversions</span>.
- <span class="em2">Ownership and explicit transfer</span> with `move` and `copy`.
Expand All @@ -12,6 +13,7 @@
- <span class="em3">Non-storable view types</span> prevent accidental long-lived borrows: `ref`, `str`, and `slice`.
- `defer` statement for <span class="em3">deterministic resource management</span>.
- <span class="em4">Algebraic data types</span> (ADTs) with first-class support for `enum` and `struct`.
- <span class="em4">First-class record types</span> with closed structural shape and strict field-based identity.
- <span class="em4">Pattern matching</span> with exhaustive checks and irrefutable patterns.
- <span class="em4">Generics and protocols</span> with associated types keep abstractions precise.
- <span class="em4">Opaque return types</span> with `some`, preserving static dispatch.
Expand Down