Robbert van Dalen
2013-05-27 19:30:51 UTC
positional postfix evaluation
- please set the font to mono-spaced for better readability -
this short post describes a novel (postfix) computational model that may interest you.
it has the following properties:
1) atoms in (sub)expressions take position and are evaluated in-position
2) an atom can be a subexpression, syntactically surrounded by parenthesis
3) parenthesis are transparent, while evaluating an expression
4) expressions are evaluated in parallel
let me present the canonical example:
1 2 + 3 4 + * =>
3 7 * =>
21
.. demonstrating property 1 and 4.
so why the need for positions?
it allows the data flow of a program to be easily eyeballed.
here is another example:
(1 2) + 3 (4 (+ *)) =>
3 ( (7 *)) =>
( (21))
.. which demonstrates property 2 and 3.
it also demonstrates that parenthesis - which are transparent - retain their position after evaluation.
but notice that the postfix evaluation of subexpressions are less easily eyeballed.
so why the need for subexpressions and parenthesis?
solely because of efficiency reasons.
the following example shows the efficient in-place substitution and evaluation of subexpressions:
e1 == 1 2 +
e1 => 3
e2 == 3 4 +
e2 => 7
e3 == e1 e2 *
e3 == (1 2 +) (3 4 +) *
e3 => ( 3) ( 7) *
e3 => 21
here is an 'explicit' positional representation of the same substitutions:
e1 == 0=1 1=2 2=+
e1 => 2=3
e2 == 0=3 1=4 2=+
e2 => 2=7
e3 == e1 e2 *
e3 => 0=(0=1 1=2 2=+) 1=(0=3 1=4 2=+) 2=*
e3 => 0=( 2=3) 1=( 2=7) 2=*
e3 => 2=21
note that all this is implemented in the spread programming language v0.2.
care to comment?
please do!
cheers,
robbert
[Non-text portions of this message have been removed]
- please set the font to mono-spaced for better readability -
this short post describes a novel (postfix) computational model that may interest you.
it has the following properties:
1) atoms in (sub)expressions take position and are evaluated in-position
2) an atom can be a subexpression, syntactically surrounded by parenthesis
3) parenthesis are transparent, while evaluating an expression
4) expressions are evaluated in parallel
let me present the canonical example:
1 2 + 3 4 + * =>
3 7 * =>
21
.. demonstrating property 1 and 4.
so why the need for positions?
it allows the data flow of a program to be easily eyeballed.
here is another example:
(1 2) + 3 (4 (+ *)) =>
3 ( (7 *)) =>
( (21))
.. which demonstrates property 2 and 3.
it also demonstrates that parenthesis - which are transparent - retain their position after evaluation.
but notice that the postfix evaluation of subexpressions are less easily eyeballed.
so why the need for subexpressions and parenthesis?
solely because of efficiency reasons.
the following example shows the efficient in-place substitution and evaluation of subexpressions:
e1 == 1 2 +
e1 => 3
e2 == 3 4 +
e2 => 7
e3 == e1 e2 *
e3 == (1 2 +) (3 4 +) *
e3 => ( 3) ( 7) *
e3 => 21
here is an 'explicit' positional representation of the same substitutions:
e1 == 0=1 1=2 2=+
e1 => 2=3
e2 == 0=3 1=4 2=+
e2 => 2=7
e3 == e1 e2 *
e3 => 0=(0=1 1=2 2=+) 1=(0=3 1=4 2=+) 2=*
e3 => 0=( 2=3) 1=( 2=7) 2=*
e3 => 2=21
note that all this is implemented in the spread programming language v0.2.
care to comment?
please do!
cheers,
robbert
[Non-text portions of this message have been removed]