lazy object evaluation little language
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)
exprs separator expr
- First evaluates
exprs
and if that does not returnfailure
then 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
scope
property. expr # closure
- Evaluate a closure, using
expr
as scope. expr < exprs >
-
Creates a new object, using
expr
as prototype (stored in theproto
property). The current scope is stored in thescope
property. Ifexpr
is ommited,Any
is used.exprs
is evaluated in the current scope, but withcurrent
set 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
this
set to the left value, andthat
set 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.
expr.ident
expr.ident = expr- Gets/sets a property.
.ident
.ident = expr
.(exprs)
.(exprs) = expr- Gets/sets a property of
this
inside a closure definition, or of thecurrent
inside an object definition. { \ident separator exprs }
- Creates a closure. The value of
that
is assigned toident
. (This makesident
the 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
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
this
is notfailure
. Use a closure if you want short-circuiting. (similar to&&
in Javascript) else
- Evaluates the argument if
this
isfailure
. Use a closure if you want short-circuiting. (similar to||
in Javascript)
These methods are defined:
+
- list concatenation
item
n
- Get the
n
th item from the list. all
closure
- Returns a new list by calling
closure
once for every item, passing each item as the argument toclosure
. The result ofclosure
is used as the given item in the new list. If a call fails,all
fails. some
closure
- Returns a new list by calling
closure
once for every item, passing each item as the argument toclosure
. The result ofclosure
is used as the given item in the new list, if the call succeeds.some
can be used to filter a list.
These methods are defined:
closureA
|
closureB
- Creates a new closure, that first calls
closureA
, then callsclosureB
if that fails.
The syntax is equivalent to javascript. These methods are defined:
+
- string concatenation
==
!=
- test for (in)equality
The syntax is equivalent to javascript. These methods are defined:
+
-
*
/
- arithmetic
lt
gt
- less than and greater than tests
==
!=
- test for (in)equality
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
failure
intosuccess
, and anything else intofailure
.