F.E.L.T.

Functionally Equivalent Language Translation

INCR

(incr var-name [ delta ] )

(incr x)              ; non-destructivley increments x by 1 for evaluation
(incr x 2)            ; by 2
(incr x (get-mode))   ; by whatever (get-mode) returned

See also DECF DECR INCF

This will destructivley modify the contents of the target variable by the amount specified, with the default being one. The optional delta value can be any valid expression for the target language and it will be applied at run-time.


Non-Destructive Increment

What this means is that the targeted variable has the supplied delta expression applied to it but only for the duration of the expression. Some examples will make this clear; the idiom is very common and you will reocgnise it immediately!

(defvar x 42)
(emit "x plus ten: " (incr x 10) "\n")
(emit "x is still: " x "\n")

This generate the following PHP:

$x = 42;
echo "x plus ten: ", ($x+10), "\n";
echo "x is still: ", $x, "\n";

When executed the above produces:

$ felt docex.felt -cw | php
x plus ten: 52
x is still: 42

And the javaScript as well (piped through Nodejscoder):

var x = 42;
console.log("x minus ten: "+ (x+10)+ "\n");
console.log("x is still: "+ x+ "\n");

Which when piped through the Node.js coder gives us this output:

$ felt docex.felt -as nodejscoder | node
x plus ten: 52

x is still: 42