I have been developing DeltaScript for the scriptable pixel art editor that I am working on, but I have plans to reuse it for other projects with entirely separate scopes in the future.
I have implemented DeltaScript as an interpreter that targets Java. However, DeltaScript is technically target-agnostic, and could be implemented as a compiled or interpreted language. I haven't gotten round to documenting or specifying the language yet, but the syntax grammar and implementation are both available.
DeltaScript's syntax is C-like, and most of the keywords and syntactical conventions I opted for fall firmly within that family. However, I wanted to do something more unique with my version of switch statements.
Switch statements have a *control expression*. That is the expression whose value is checked against in the statement's cases. Rather than simply comparing the control to possible values, I wanted to be able to pattern match the control expression. So, I devised the `when` statement, which has two separate types of non-trivial cases: `is` and `passes`.
`is` is a conventional switch case, which provides an expression pf the same type as the control expression to compare it to. If the values are equal (`==`) as defined by the type, the body of the `is` case is executed.
`passes`, on the other hand, provides a test. For a control expression of type `T`, passes provides a function of type `(T -> bool)`; that is, a function that takes a single parameter of type `T` and returns a truth value. The control expression is passed into the test, and the body of the `passes` case is executed if and only if the test returns `true`.
The test can be provided as a direct function pointer, a variable storing a function, or a lambda expression.
Let me know what you think!