Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the lila Reference Manual, version 28, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 04:56:52 2022 GMT+0.
Next: Systems, Previous: The lila Reference Manual, Up: The lila Reference Manual [Contents][Index]
lila is a cleaner, less nested and more declarative language based on Common Lisp.
fun fib(n:Int) {
if {n.< 2} n {
{fib; n.- 1}.+ {fib; n.- 2}
}
}
The following command sequence should take you from zero to REPL.
Note that SBCL and Quicklisp are required to build lila.
$ git clone https://github.com/codr7/lila.git
$ cd lila
$ ln -s "$(pwd)/lila.asd" ~/quicklisp/local-projects
$ mkdir dist
$ ./makedist
$ dist/lila
lila
Press Return on empty row to evaluate.
* 6 7
42
The current implementation weighs in below 1 kloc and supports everything described in this document.
$ dist/lila -build dist/test test/suite.lila
$ dist/test
Functions and macros are generic with fixed arity. Bare names evaluate to calls and consume the same number of forms as specified arguments.
* 6 7
42
Curlies allow grouping forms and controlling evaluation order.
{* 6 {+ 3 4}}
42
In simple cases such as previous example, ;
may be used to reduce nesting.
{* 6; + 3 4}
42
Dot notation allows putting the called macro/function infix.
21.neg.* 2
-42
is
returns true
when both arguments share the same identity.
42.is 42
true
For reference types, such as lists; identity means address.
(42).is (42)
false
equals
may be used to compare values.
(42).equals (42)
true
Values may be bound to names using var
.
{
var foo 42
foo
}
42
Bound values may be changed using =
, which is a regular macro. Assignments evaluate to the new value, 3
in the following example.
{
var foo 1
+ {foo.= 3} 5
}
8
Changing non-existing bindings triggers compile time errors.
foo.= 42
System error at row 1, col 0: Unknown id: foo
Constant bindings are evaluated at compile time and inlined on reference.
{
const FOO 42
FOO
}
42
Changing constant bindings triggers compile time errors.
{
const FOO 1
FOO.= 3
}
System error at row 3, col 2: Can't rebind const: FOO
Meta
is the type of all types, including itself.
Meta.type-of
Meta
None
represents missing values and has exactly one instance named _
.
_.type-of
None
Suffixing any type except None
with ?
evaluates to a sum type that matches the specified type and None
.
None.is-a Int
false
None.is-a Int?
true
Booleans can be true
or false
.
All values have boolean representations; many are unconditionally true
, 0
and empty lists being two notable exceptions.
0.bool
false
(1 2 3).bool
true
Logical operators are binary, short-circuiting and return the last evaluated argument.
true.and 42
42
42.or false
42
Pairs allow treating two values as one.
{
var foo 1:2
foo
}
1:2
Pairs are closely related to lists, zipping any value with the empty list evaluates to a single-element list.
42:()
(42)
Parts may be extracted using deconstructing bindings.
{
var foo {1:2}
var a:b foo
b:a
}
2:1
Functions are generic with fixed arity.
Arguments have type Any
by default, which doesn't allow missing values. Calling missing functions triggers compile time errors.
{
fun foo(x) {42}
_.foo
}
debugger invoked on a SB-PCL::NO-APPLICABLE-METHOD-ERROR
When allowing missing values is exactly what you want, specifying the argument type is all it takes.
{
fun foo(x:Any?) {42}
_.foo
}
42
By default, functions return the value of the last evaluated form. Return may be used to exit early with optional result.
{
fun foo() {1 return 2 3}
foo
}
2
Sum types match any member type.
Int/Bool
Int/Bool
Int.is-a Int/Bool
true
Optimization level may be set by passing -speed
on the command line. The accepted range is 0
-9
, with 9
being the fastest and 0
default.
$ dist/lila bench/pair.lila
72
$ dist/lila -speed 9 bench/pair.lila
4
Please consider donating if you would like to help the project evolve and improve.
Next: Files, Previous: Introduction, Up: The lila Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
a cleaner language based on Common Lisp
codr7
codr7
MIT
28
Next: Packages, Previous: Systems, Up: The lila Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: lila/src/util.lisp, Previous: lila/lila.asd, Up: Lisp [Contents][Index]
lila (system).
lila.
lila-version (symbol macro).
Next: lila/src/pos.lisp, Previous: lila/src/lila.lisp, Up: Lisp [Contents][Index]
src/lila.lisp (file).
lila (system).
Next: lila/src/error.lisp, Previous: lila/src/util.lisp, Up: Lisp [Contents][Index]
src/util.lisp (file).
lila (system).
print-object (method).
Next: lila/src/id.lisp, Previous: lila/src/pos.lisp, Up: Lisp [Contents][Index]
src/pos.lisp (file).
lila (system).
print-object (method).
Next: lila/src/type.lisp, Previous: lila/src/error.lisp, Up: Lisp [Contents][Index]
src/error.lisp (file).
lila (system).
Next: lila/src/arg.lisp, Previous: lila/src/id.lisp, Up: Lisp [Contents][Index]
src/id.lisp (file).
lila (system).
Next: lila/src/macro.lisp, Previous: lila/src/type.lisp, Up: Lisp [Contents][Index]
src/type.lisp (file).
lila (system).
Next: lila/src/fun.lisp, Previous: lila/src/arg.lisp, Up: Lisp [Contents][Index]
src/arg.lisp (file).
lila (system).
print-object (method).
Next: lila/src/undef.lisp, Previous: lila/src/macro.lisp, Up: Lisp [Contents][Index]
src/macro.lisp (file).
lila (system).
print-object (method).
Next: lila/src/sym.lisp, Previous: lila/src/fun.lisp, Up: Lisp [Contents][Index]
src/fun.lisp (file).
lila (system).
Next: lila/src/env.lisp, Previous: lila/src/undef.lisp, Up: Lisp [Contents][Index]
src/undef.lisp (file).
lila (system).
Next: lila/src/plugin.lisp, Previous: lila/src/sym.lisp, Up: Lisp [Contents][Index]
src/sym.lisp (file).
lila (system).
Next: lila/src/val.lisp, Previous: lila/src/env.lisp, Up: Lisp [Contents][Index]
src/env.lisp (file).
lila (system).
link (function).
Next: lila/src/bool.lisp, Previous: lila/src/plugin.lisp, Up: Lisp [Contents][Index]
src/plugin.lisp (file).
lila (system).
Next: lila/src/dot.lisp, Previous: lila/src/val.lisp, Up: Lisp [Contents][Index]
src/val.lisp (file).
lila (system).
Next: lila/src/expr.lisp, Previous: lila/src/bool.lisp, Up: Lisp [Contents][Index]
src/bool.lisp (file).
lila (system).
print-object (method).
Next: lila/src/int.lisp, Previous: lila/src/dot.lisp, Up: Lisp [Contents][Index]
src/dot.lisp (file).
lila (system).
print-object (method).
Next: lila/src/list.lisp, Previous: lila/src/expr.lisp, Up: Lisp [Contents][Index]
src/expr.lisp (file).
lila (system).
Next: lila/src/str.lisp, Previous: lila/src/int.lisp, Up: Lisp [Contents][Index]
src/int.lisp (file).
lila (system).
Next: lila/src/sum.lisp, Previous: lila/src/list.lisp, Up: Lisp [Contents][Index]
src/list.lisp (file).
lila (system).
Next: lila/src/read.lisp, Previous: lila/src/str.lisp, Up: Lisp [Contents][Index]
src/str.lisp (file).
lila (system).
Next: lila/src/compile.lisp, Previous: lila/src/sum.lisp, Up: Lisp [Contents][Index]
src/sum.lisp (file).
lila (system).
Next: lila/src/io.lisp, Previous: lila/src/read.lisp, Up: Lisp [Contents][Index]
src/read.lisp (file).
lila (system).
Next: lila/src/repl.lisp, Previous: lila/src/compile.lisp, Up: Lisp [Contents][Index]
src/compile.lisp (file).
lila (system).
Next: lila/src/libs/abc.lisp, Previous: lila/src/io.lisp, Up: Lisp [Contents][Index]
src/io.lisp (file).
lila (system).
repl (function).
Next: lila/src/libs/io.lisp, Previous: lila/src/repl.lisp, Up: Lisp [Contents][Index]
src/repl.lisp (file).
lila (system).
Next: lila/src/libs/math.lisp, Previous: lila/src/libs/abc.lisp, Up: Lisp [Contents][Index]
src/libs/abc.lisp (file).
lila (system).
Previous: lila/src/libs/io.lisp, Up: Lisp [Contents][Index]
src/libs/io.lisp (file).
lila (system).
init-math (function).
Next: Definitions, Previous: Files, Up: The lila Reference Manual [Contents][Index]
Packages are listed by definition order.
common-lisp.
lila-version (symbol macro).
Next: Indexes, Previous: Packages, Up: The lila Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Standalone methods, Previous: Public Interface, Up: Public Interface [Contents][Index]
Previous: Symbol macros, Up: Public Interface [Contents][Index]
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Symbol macros, Previous: Internals, Up: Internals [Contents][Index]
Next: Macros, Previous: Special variables, Up: Internals [Contents][Index]
Next: Ordinary functions, Previous: Symbol macros, Up: Internals [Contents][Index]
Next: Generic functions, Previous: Macros, Up: Internals [Contents][Index]
Next: Conditions, Previous: Ordinary functions, Up: Internals [Contents][Index]
lila.
lila.
lila.
Next: Classes, Previous: Generic functions, Up: Internals [Contents][Index]
lila.
error.
Previous: Conditions, Up: Internals [Contents][Index]
lila.
Previous: Definitions, Up: The lila Reference Manual [Contents][Index]
Jump to: | (
C D E F G I L M N O P R S T U V W |
---|
Jump to: | (
C D E F G I L M N O P R S T U V W |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | *
_
A B C D E F I L M N O P R S T U V |
---|
Jump to: | *
_
A B C D E F I L M N O P R S T U V |
---|
Jump to: | _
A B C D E F I L M N P S T U |
---|
Jump to: | _
A B C D E F I L M N P S T U |
---|