diff --git a/index.html b/index.html index 1bd5953..aa34c00 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ - + @@ -105,18 +105,21 @@ version = 1.1 // Assignment ## The Block: A Unified Structure -The \`{}\` syntax creates a **Block**, the foundational structure in Hi. A Block is a container for both properties (state) and executable code (behavior), functioning simultaneously as a callable object and a stateful function. +The \`{}\` syntax creates a **Block**, the foundational structure in Hi. A Block can be used as a function, an object, or an object with methods. ### Function Block -A Block with only executable code is a function. +A Block with executable code is a function. Parameters are defined with \`()\`. \`\`\`javascript sayHi: { _("Hi") } sayHi() // Invokes the block + +greet: (name) { _("Hi, " + name) } +greet("Orion") \`\`\` ### Object Block -A Block with named properties is an object. A \`#\` prefix denotes a private property, inaccessible from outside the block's scope. +A Block with named properties is an object. A \`#\` prefix denotes a private property. \`\`\`javascript player: { @@ -126,8 +129,7 @@ player: { _(player.name) // "Orion" \`\`\` -### Hybrid Block -Blocks can contain both state and methods. Inner blocks lexically inherit the scope of their parent, allowing them to access and mutate the parent's private state. This provides true encapsulation without classes. +An object's properties can be functions (other blocks). Inner blocks inherit the parent's scope, allowing them to access private state. This provides encapsulation without classes. \`\`\`javascript counter: { @@ -140,13 +142,6 @@ counter.inc() _(counter.get()) // Prints 1 \`\`\` -### Blocks with Parameters - -\`\`\`javascript -greet: (name) { _("Hi, " + name) } -greet("Orion") -\`\`\` - ## 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. @@ -406,4 +401,3 @@ To create the initial Hi-to-JS transpiler, the following primitives and built-in -