top | item 42723998

When to Say When: Reinventing the Switch Statement

2 points| flinkerflitzer | 1 year ago |jbunke.github.io

1 comment

order

flinkerflitzer|1 year ago

I designed and implemented my own scripting language, which features a control flow structure I wanted to get some feedback on!

The `when` statement in DeltaScript extends the traditional `switch` statement with types of cases for pattern matching and testing the control variable against a boolean function (predicate). It also does away with fallthrough.

Read about the semantics in detail: https://github.com/jbunke/deltascript/blob/master/docs/ls-5-... Download the entire language specification and/or play with the Java interpreter: https://github.com/jbunke/deltascript/releases/tag/v0.1.0