Saturday, August 1, 2009

More details about my functional language

I figured I'd elaborate on the as of yet nameless functional language I posted about earlier today.

It's defining feature is that it really ships as a blank slate. Virtually everything you find in a functional language like Lisp or Haskell is so trivial to implement, it doesn't make any sense to hardwire it into the language specifications.

This is because it isn't so much as a language as it is a programmable language parser combined with some very crude elements, lists and atoms, that combined allows you to formulate a functional language.

The latest addition to the language specifications (it's still being evaluated to see just how well it works out) is pattern meta-matching. That is, a pattern that compares stack nodes with other patterns (or even itself). This turned out to make the language even more versatile. It's trivially easy to implement a type system with this latest feature.

It works like this: First you define a tautological pattern that consists of a tag, and the the internals of your type.

define ( =car-tag seats color ) Car ( car-tag seats color );

That's it. You have now defined a type called Car, that has two fields: seats and color. You can now create functions that take a car as an argument.

define ( c:Car ) car-get-seats ( c.seats );
define ( c:Car ) car-get-color ( c.color );

You can of course also modify objects in this fashion:

define ( c:Car new-color ) car-repaint ( car-tag c.seats new-color );

It's important to repeat, that this language does NOT have a type system. It has a variety of pattern matching that you can use to implement types. Or to translate infix mathematics to polish notation. Or countless other applications.

No comments:

Post a Comment