A bit of curry?

I’m talking about Currying, “the technique of transforming a function that takes multiple arguments into a function that takes a single argument…”

With two recent additions to Prexonite (Script), it has become very easy to implement higher-order functions, including “curry” and “uncurry”.

With “additions” I’m referring to Closures as a virtual machine feature and Lambda Expressions as a Prexonite Script expansion. Something of the form (a1, a2, a3, … , an) => expr is an expression that is compiled into a separate function. Instead of a value, such a construct returns a closure, an enhanced reference to that anonymous function, that acts like a normal function reference. It get’s even better: As this so called lambda expression is defined inside another function, you can use local variables as if they were part of the expression. That’s also the reason why this closure-thingy is returned instead of a normal function reference: It carries information about additional local variables available to the lambda expression. More »

Fancy Beer

I’m close to reaching my first milestone: Support for all common language constructs. What do I mean by “common”? The minimum requirements for the language to be useful if you want.

With the recent addition of commands, the virtual machine is now complete and waits for the compiler and type system to catch up.

The foreach loop is ready to be used and accepts both Prexonite Lists (mixed values) and pure CLI IEnumerables. Also built into my current version is support for global code* and build blocks**.

Global code:
Allows you to initialize (and re-initialize) global variables. Those instructions are executed the next time a function is run.

Build block:
Introduced by the build keyword. It gives you control over the loader at compile time. You can use the special commands Add and Require to load additional files into the current application. (Require only loads a file if it hasn’t been loaded before.)

Prexonite, interactive beer session
Here I first compiled the script samples\beer_fancy.pxs into the file beer.pxs, then loaded that file in an interactive session and finally executed the song function with a custom argument. All text output is exclusively generated by Prexonite code. (Yes, this also includes the interactive interface).