From 50b8acc963a365e2d5f7e2cfce6398a544670f99 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Mon, 22 Sep 2025 12:41:32 -0700 Subject: [PATCH] Refactor: Move Block separator info to section end --- index.html | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index e07e4c7..84069fb 100644 --- a/index.html +++ b/index.html @@ -111,25 +111,18 @@ version = 1.1 // Assignment In Hi, the distinction between objects and functions is eliminated. Both concepts are unified into a single, foundational structure: the **Block** (\`{}\`). A Block is a sequence of expressions that can hold data, executable code, or both, making it a powerful tool for building complex structures. ### As a Data Structure (Object) -When a Block contains primarily named declarations (\`key: value\`), it behaves like a traditional object or dictionary. A \`#\` prefix denotes a private property. +When a Block contains primarily named declarations (\`key: value\`), it behaves like a traditional object or dictionary. A \`#\` prefix denotes a private property, making it inaccessible from outside the block. \`\`\`javascript -// Multi-line: separators are optional player: { name: "Orion" #hp: 100 } -// Single-line: separators are required -player: { name: "Orion", #hp: 100 } -point: { x: 10; y: 20 } +_(player.name) // "Orion" +_(player.hp) // -0 (null) because #hp is private \`\`\` -To support code golfing, expression separators are flexible: - -- **Newlines** act as separators. Commas or semicolons are optional. -- **Commas (\`,\`) or semicolons (\`;\`)** must be used to separate expressions on the same line. - ### As Executable Code (Function) When a Block is defined with parameters (\`()\`) or invoked, it behaves like a function. It executes its sequence of expressions. @@ -155,6 +148,21 @@ counter.inc() _(counter.get()) // Prints 1 \`\`\` +### Expression Separators +To support code golfing, expression separators within a Block are flexible. Newlines act as implicit separators, while commas (\`,\`) or semicolons (\`;\`) are required to separate expressions on the same line. + +\`\`\`javascript +// Multi-line style (separators optional) +point: { + x: 10 + y: 20 +} + +// Single-line style (separators required) +point: { x: 10, y: 20 } +point: { x: 10; y: 20 } +\`\`\` + ## Arrow Expressions For concise single-expression functions, Hi provides the \`=>\` arrow syntax, inspired by JavaScript. It serves as a shorthand for a Block that immediately returns an expression, making it ideal for callbacks and functional patterns.