| examples | More features (optional peek, lambdas, tailcalls, primitives, examples) | |
| libs | More features (optional peek, lambdas, tailcalls, primitives, examples) | |
| endless.lua | More features (optional peek, lambdas, tailcalls, primitives, examples) | |
| LICENSE | initial commit | |
| pprint.lua | initial commit | |
| README.md | initial commit | |
Endless
You stand surrounded by a sprawling hexigonal library. Every room is filled with stacks of books, each labelled with a name. When you open one of these books you are teleported to a nearly identical library. The only difference is the labels and books have changed. After some time, you get a sense that the space you find yourself in is truly Endless.
Endless is a prototype-based concatenative programming language. Instead of just one data stack, Endless features unlimited named data stacks which values can be moved in and out of. Additionally, objects themselves are all bundles of named stacks. Values can be sent between objects or an object be made into the current context for all operations. This allows for code to be highly composeable.
State of Endless
Endless currently exist as a proof of concept, currently the language has no flow control primitives.
Examples
Basic Operations
: magnitude ( :x :y -- :magnitude )
x@ x@ * y@ y@ * + sqrt >magnitude ;
3 >x 4 >y magnitude magnitude> print
Objects
: print-message ( :message -- )
message> #text@ print ;
: make-message ( string -- message )
object >message
message@ swap >text# ;
"hello, world!" make-message print-message ;
Methods
Print Message
( lets turn print-message into a method )
: :print-message ( message -- message )
enter text@ print leave ;
"hello, world!" make-message :print-message ;
Magnitude
(
The magnitude function from before needs
no modification to be wrapped into a method
)
: magnitude ( :x :y -- :x :y :magnitude )
x@ x@ * y@ y@ * + sqrt >magnitude;
( compute the magnitude and emit it to a parent scope )
: ^magnitude ( :parent :magnitude -- )
magnitude parent@ magnitude@ >magnitude# ;
( define a method for vector2 )
: :magnitude ( vector2 -- vector2 magnitude )
enter ^magnitude leave magnitude> ;
( a constructor for a vector2 object )
: new-vector2 ( :x :y -- vector2 )
object
dup x> >x#
dup y> >y# ;
( Finally, we can run our method )
point@ :magnitude print