Anonymous user
Category:Lambdatalk: Difference between revisions
m
→{lambda talk} full: adding a new link
No edit summary |
m (→{lambda talk} full: adding a new link) |
||
(18 intermediate revisions by 2 users not shown) | |||
Line 1:
{{language|Lamdatalk}}
The {lambda way} project is a web application built on two engines:
Line 7 ⟶ 8:
2) {lambda talk}, a purely functional language unifying authoring, styling and scripting in a single and coherent s-expression based syntax.
==
1) Expressions are written in a prefix notation using curly braces.
Line 16 ⟶ 17:
-> 2+3 is equal to 5
{def foo
Line 25 ⟶ 26:
-> 2+3 is equal to 5
==
{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]*
Line 49 ⟶ 50:
{def word expression}
allowing to create constants added to the dictionary and to give names to anonymous functions.
What can be done with so little?
===Examples===
Hello World
-> Hello World
▲Out of curly braces words are not evaluated.
{def HI Hello World}
Line 65 ⟶ 68:
-> HI, I just say Hello World
Abstractions can be defined and immediately called:
▲Sequences of words can be given a name.
{{lambda {
-> World Hello
The abstraction {lambda {:a :b} :b :a} is
Abstractions can be given a name and then called easily several times:
{def GOOD_DAY {lambda {o a} oh happy day!}} ▼
{GOOD_DAY oOOOo aaAaa} ▼
-> swap
{
->
-> Bond James
Most of the time expressions are nested. The expression below returns the first word of Hello World:
Line 93 ⟶ 98:
{def CDR {lambda {:z} {:z {lambda {:x :y} :y}}}} -> CDR
{CAR {CONS Hello World}} -> Hello
{
===about the implementation===
Line 108 ⟶ 113:
};
'''1) eval_forms()''': 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.
- lambdas are '''first class functions''', they can be called as functions' arguments and returned from functions,
Line 116 ⟶ 121:
- 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
- lambdas are '''variadic''': called with a number of values greater than its arity, a lambda feeds the extra values in the last argument.
'''Note:''': This is what Ward Cunningham wrote about such an iconoclastic implementation: ''« I was surprised that the technique worked so well in so many cases. I knew that regex are highly optimized and the cpus themselves optimize sequential access to memory which the regex must have at its core. [..] Yes, this has at its heart the repeated application of a text transformation. The fact that it is repeated application of the same transformation makes it exceptional. [..] Repeated application of Regular Expressions can perform Touring Complete computations. This works because the needed "state" is in the partially evaluated text itself. »'' All is said!
===and?===
Upon these foundations, after '''Alonzo Church''', we could define the set of natural numbers [ZERO, ONE, TWO, ...] and their associate operators, [SUCC, ADD, MUL, POWER, PRED, ...] allowing to build '''
{CHURCH
Line 133 ⟶ 142:
-> 120
==
In its complete state, {lambda talk} comes with a more complete set of special forms, [
{def ! {lambda {:a :b}
{if {< :b 2}
then :a
else {! {* :a :b} {- :b 1}}}}}
-> !
{! 1 6}
-> 720
What for? Well, you could compute the famous Euler's number:
▲But {lambda talk} can take benefit from the extraordinary power of modern '''web browsers''' and, without ''re-inventinging the wheel'', {lambda talk} simply adds a coherent and unique language on existing tools.
{def euler {lambda {:n}
▲In its complete state, {lambda talk} comes with a more complete set of special forms, ['''lambda''', '''def''', if, let, quote, macro, require, script, style], and a dictionary containing about 200 primitives built on Javascript Math object, HTML tags and CSS rules, the DOM and more, pairs, lists, arrays, ... and some other specific to the wiki context.
{+ {map {lambda {:n} {/ 1 {! 1 :n}}} {serie 0 :n}}}}}
-> euler
{euler 17}
-> 2.7182818284590455
Web design is not forgotten and examples can be seen in the workshop's website. Thanks to the language's unicity, authors, web-designers and coders can share their experiences to build rich web pages.
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 (50kb) 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.▼
▲The {lambda way} project adds on browsers a thin overlay, {lambda tank},
A full presentation of the {lambda way} project can be seen in this version: http://lambdaway.free.fr/lambdaspeech followed by this last one under construction: http://lambdaway.free.fr/lambdawalks
Your opinion is welcome. Alain Marty
|