This crate provides you with a small and simple embeddable scripting language. It's primary feature are functions and calling functions. It could be viewed as Lisp without parenthesis.
Here are some of it's properties:
The API relies on a data structure made of VVal nodes.
Just a quick glance at the WLambda syntax and semantics.
```wlambda
!a = 10;
.a = 20;
!a_list = $[1, 2, 3, 4];
!a_map = ${a: 10, b: 20};
!a_func = { _ + _2 # Arguments are not named, they are put into _, _2, _3 };
afunc(2, 3); # Function call afunc 2 3; # Equivalent function call
if
statement. Booleans can be called[a == 10] { # called if a == 10 } { # called if a != 10 }
!:ref sum = 0; # Defining a reference that can be assignment # from inside a function.
range
calls the given function for each iteration_
range 0 10 1 { # This is a regular function. sum = sum + _; }
range
loop with break
!breakvalue = range 0 10 1 { [ == 5] { break 22 }; };
!someobj = ${}; someobj.dosomething = { # do something here }; someobj.do_something(); # Method call ```
Currently there are many more examples in the test cases in compiler.rs
.
The API is far from feature complete, but this is roughly how it looks currently:
``` use wlambda::prelude::createwlambaprelude;
let s = "$[1,2,3]"; let r = wlambda::compiler::eval(&s).unwrap(); println!("Res: {}", r.s()); ```
There are several things that can be added more or less easily to WLambda. But I am currently working on making the language more complete for real world use. So my current goals are:
panic
and assert
and also make the compiler aware of
the debugging positions that the parser augmented the AST with for
error reporting.Future plans could be:
Prototyped inheritance, sketched out like this:
```wlambda !proto = ${ print: { println _ }, }; !o = toobj { _proto: proto }; o.print(123);
# MetaMap(Rc<RefCell<std::collections::HashMap<String, VVal>>>),
# => invokes _proto_ lookup on field access (not write)
```
Augment functions with tagged values:
```wlambda !tag = 123; !v = tag 10 tag; !fun = { println("not tagged!") }; .fun = add_tag fun tag { println("tagged with 123"); } fun(v); # prints "tagged with 123" fun(10); # prints "not tagged!"
# TagFun(Rc<RefCell<std::collections::HashMap<String, Rc<VValFun>>>>),
```
There are currently no plans to change the internal evaluator from a closure tree to a VM and/or JIT speedup. However, if someone is able to significantly speed up the evaluation this can be changed.
This project is licensed under the GNU General Public License Version 3 or later.
Picking a license for my code bothered me for a long time. I read many discussions about this topic. Read the license explanations. And discussed this matter with other developers.
First about why I write code for free at all:
Those are the reasons why I write code for free. Now the reasons why I publish the code, when I could as well keep it to myself:
Most of those reasons don't yet justify GPL. The main point of the GPL, as far as I understand: The GPL makes sure the software stays free software until eternity. That the user of the software always stays in control. That the users have at least the means to adapt the software to new platforms or use cases. Even if the original authors don't maintain the software anymore. It ultimately prevents "vendor lock in". I really dislike vendor lock in, especially as developer. Especially as developer I want and need to stay in control of the computers I use.
Another point is, that my work has a value. If I give away my work without any strings attached, I effectively work for free. Work for free for companies. I would compromise the price I can demand for my skill, workforce and time.
This makes two reasons for me to choose the GPL:
Please contact me if you need a different license and really want to use my code. As long as I am the only author, I can change the license. We might find an agreement.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in WLambda by you, shall be licensed as GPLv3 or later, without any additional terms or conditions.
WeirdConstructor
on the Rust Discord.)