Loell
lazy object evaluation little language
Last Update
10/16/2005; 1:22:40 AM
Loell is an experimental programming language in development. The idea is to have a small core with a lot of power. For the rest I plan to use it to try out new language ideas, which I usually get from Lambda the Ultimate. The focus is on testing out language features that improve productivity, like goal directed programming, helpful typing features, readability and building abstractions.
Try some code:
- Load object oriented sample code
- Load functional programming sample code
- Load 'macro' sample code
- Load shapes sample code (see Chris Rathman's OO Shape Examples)
- Load Haskell-esque sample code (see haskell.org)
- Load recursion overriding sample code (see LtU discussion)
Core syntax
exprs separator expr- First evaluates
exprsand if that does not returnfailurethen returnsexpr. Valid expression separators are;and a new line, if the indentation on the new line is not bigger than the indentation of the line of the start of the expression. -
expr.(exprs)
expr.(exprs) = expr - Gets/sets a property.
{ exprs }- Creates a closure, the current scope is stored in the
scopeproperty. expr # closure- Evaluate a closure, using
expras scope. expr < exprs >-
Creates a new object, using
expras prototype (stored in theprotoproperty). The current scope is stored in thescopeproperty. Ifexpris ommited,Anyis used.exprsis evaluated in the current scope, but withcurrentset the newly created object. expr closure expr- Simulates a method call. (object method argument)
The closure is called with the scope it was defined in,
but with
thisset to the left value, andthatset to the right value. expr ident= expr- A method call, where the object is set to the result.
$- The current scope.
-
ident
ident = expr - Gets/sets a property of the current scope
[ exprs ]- Creates a list, with for each expression an element with the value of that expression.
Shortcut syntax
-
expr.ident
expr.ident = expr - Gets/sets a property.
-
.ident
.ident = expr
.(exprs)
.(exprs) = expr - Gets/sets a property of
thisinside a closure definition, or of thecurrentinside an object definition. { \ident separator exprs }- Creates a closure. The value of
thatis assigned toident. (This makesidentthe argument name for methods) The identifier may be extended to a test expression. ident- Proper identifier tokens are: /[A-Za-z_][A-Za-z0-9_]*/,
==,!=or any combination of* + - & ^ ? | / /*...*/ //...- Javascript style comments are supported
All objects
These methods are defined:
-
==!= - test if it is (not) the same object
isA- test if the argument is a prototype of this object
then- Evaluates the argument if
thisis notfailure. Use a closure if you want short-circuiting. (similar to&&in Javascript) else- Evaluates the argument if
thisisfailure. Use a closure if you want short-circuiting. (similar to||in Javascript)
Lists
These methods are defined:
+- list concatenation
-
itemn - Get the
nth item from the list. -
allclosure - Returns a new list by calling
closureonce for every item, passing each item as the argument toclosure. The result ofclosureis used as the given item in the new list. If a call fails,allfails. -
someclosure - Returns a new list by calling
closureonce for every item, passing each item as the argument toclosure. The result ofclosureis used as the given item in the new list, if the call succeeds.somecan be used to filter a list.
Closures
These methods are defined:
-
closureA|closureB - Creates a new closure, that first calls
closureA, then callsclosureBif that fails.
Strings
The syntax is equivalent to javascript. These methods are defined:
+- string concatenation
-
==!= - test for (in)equality
Numbers
The syntax is equivalent to javascript. These methods are defined:
-
+-*/ - arithmetic
-
ltgt - less than and greater than tests
-
==!= - test for (in)equality
Booleans
Loell has basic goal directed programming support.
True is success and false is failure.
Most test methods return failure when the test failes,
and this when the test succeeds.
-
!expr - not.
Turns
failureintosuccess, and anything else intofailure.