Mike Austin's Blog

Thursday, November 17, 2005

Language ideas

Impulse is language idea I've been toying with based on predicate blocks – lexical closures that have properties similar to generic functions. I dislike special syntax for pattern matching, list comprehention, etc., and predicate blocks allow me to do both without extra syntax.

A simple block
a, b -> a * b

A predicate block
a, b [a < b] -> a * b

A predicate block passed to range.map:
1..10 map: n [% 2 == 0] -> n * n
>> 4,16,36,64,100

A multiple-predicate block passed to stream.map:
lexer-stream map: char
  [is-digit?] -> stream read-identifier
  [is-alpha?] -> stream read-number


A few more details: impulse-language.html

0 Comments:

Post a Comment

<< Home