Category:Lambdatalk: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Stub out the Lambdatalk language page) |
No edit summary |
||
Line 1: | Line 1: | ||
{{language|Lamdatalk}} |
{{language|Lamdatalk}} |
||
The {lambda way} project is a web application built on two engines: |
|||
{{stub}} |
|||
1) {lambda tank}, a tiny wiki built as a thin overlay on top of any web browser, |
|||
2) {lambda talk}, a purely functional language unifying authoring, styling and scripting in a single and coherent s-expression based syntax. |
|||
==A) {lambda talk} in few words== |
|||
1) Expressions are written in a prefix notation using curly braces. |
|||
2) Away from curly braces words are just words. |
|||
2+3 is equal to {+ 2 3} |
|||
-> 2+3 is equal to 5 |
|||
• 3) Functions are created with lambda and named with def. |
|||
{def foo |
|||
{lambda {:a :b} |
|||
:a+:b is equal to {+ :a :b}}} |
|||
-> foo |
|||
{foo 2 3} |
|||
-> 2+3 is equal to 5 |
|||
==B) {lambda talk}'s foundations== |
|||
{lambda talk} is freely inspired by the λ-calculus. At the lowest level a {lambda talk} expression is exclusively made of words, abstractions and applications: |
|||
expression is [word|abstraction|application]* |
|||
where |
|||
1) word is [^\s{}]* -> word |
|||
2) abstraction is {lambda {words} expression} -> word |
|||
3) application is {expression expression} -> words |
|||
1) a word is any character except spaces and curly braces, and is not evaluated out of curly braces, |
|||
2) an abstraction is a special form (called a function) selecting words (called arguments) in an expression (called the body), and is evaluated to a word referencing an anonymous function added to a single dictionary, initially empty, |
|||
3) an application is a simple form calling an abstraction to replace selected words by some other words (called values), and is evaluated to words. |
|||
The evaluation stops when all expressions have been replaced by words. |
|||
===Implementation=== |
|||
{lambda talk} is not implemented following the standard process, code -> tokens -> tree -> eval. The code is a string from beginning to end. At each keyboard input, the code is processed by a single function, do_eval(), which returns words sent to the browser for the final evaluation and display. |
|||
var do_eval = function( code ) { |
|||
code = pre_processing( code ); |
|||
code = eval_lambdas( code ); // {lambda {args} body} |
|||
code = eval_defs( code ); // {def name body} |
|||
code = eval_forms( code ); // {a {b {c ...}}} |
|||
code = post_processing( code ); |
|||
return code |
|||
}; |
|||
Using a single regular expression the eval_forms() function loops over the code string, skips the words out of curly braces, matches nested forms {first rest} from inside out, and replaces them by words. The repeated substitutions inside the code string overcomes limitations of regular language. It's a kind of Turing machine. |
|||
The eval_lambdas() function uses arguments as Regular Expressions to successively replace occurences found in the function's body by the given values. Lambdas have the following properties: |
|||
- lambdas are first class functions, they can be called as functions' arguments and returned from functions, |
|||
- lambdas are pure black boxes, they don't create closures and are context free, inner lambdas don't see outer functions' arguments, there are no lexical scoping, no free variables, |
|||
- lambdas accept de facto partial function application: called with a number of values lesser than its arity, a lambda memorizes the given values and returns a new lambda waiting for the rest. |
|||
==B) {lambda talk} full== |
|||
In its complete state, {lambda talk} comes with more special forms, [lambda, def, if, let, quote, macro, require, script, style], and a dictionary containing about 200 primitives built on Javascript Math object, the DOM, HTML tags and CSS rules and more, pairs, lists, arrays, ... |
|||
As a dwarf standing on their shoulders, {lambda talk} takes benefit from the extraordinary power of modern web browsers. It does not re-invent the wheel and simply adds a coherent and unique language on existing tools. |
|||
The {lambda way} project adds on browsers a thin overlay, {lambda tank}, proposing a small "Interactive Development Environment" without any external dependencies and thereby easy to download and install on any web account provider running PHP. |
|||
From any web browser, on any system, complex and dynamic web pages can be created, enriched, structured and tested in real time on the web. |
|||
A full presentation of {lambda talk} can be seen in: |
|||
- http://lambdaway.free.fr/ |
|||
- http://lambdaway.free.fr/workshop/?view=about |
|||
- http://lambdaway.free.fr/workshop/?view=oxford_slides |
|||
- and several other pages of the workshop. |