Add a 'do' keyword #65

Closed
opened 2024-07-09 20:23:57 +02:00 by samvv · 1 comment
samvv commented 2024-07-09 20:23:57 +02:00 (Migrated from github.com)

The Problem

I was looking for a good way to introduce new local scopes in Bolt. Currently, Bolt does not support this syntax.

The Solution

Syntactically similar to the do keyword in Haskell, this keyword introduces a new indented block. Semantically, it can be viewed as the { ... } syntax from Rust, because each item in the block will get evaluated from top to bottom.

let foo = x * do 
   let y = 2
   y * y

foo 1 # evaluates to 4

This solution requires adjustments to the type checker and code generator.

## The Problem I was looking for a good way to introduce new local scopes in Bolt. Currently, Bolt does not support this syntax. ## The Solution Syntactically similar to the `do` keyword in Haskell, this keyword introduces a new indented block. Semantically, it can be viewed as the `{ ... }` syntax from Rust, because each item in the block will get evaluated from top to bottom. ```rust let foo = x * do let y = 2 y * y foo 1 # evaluates to 4 ``` This solution requires adjustments to the type checker and code generator.
samvv commented 2024-07-10 21:39:55 +02:00 (Migrated from github.com)

Fixed during latest refactor.

Fixed during latest refactor.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: samvv/bolt#65
No description provided.