openscad/openscad — pull request #774 by OskarLinde (2014-05-03 10:38:02+00:00)
Title: Add a let() expression

This pull request adds a let()-expression according to [a recent](http://forum.openscad.org/Variable-assignment-expression-tt7670.html) mailing-list thread.

The proposed syntax is: `let (assignments,...) expression`. A summary of design choices (open for discussion):

* The assignments are evaluated sequentially rather than in parallel as for normal function argument evaluation. For this reason, the name `let()` is chosen instead of `assign()`.
* Variables can be reassigned (same name assigned values multiple times). This is consistent with the equivalence:

let(variable1 = value1,
variable2 = value2,
variable3 = value3,
...
) expr;
being equivalent to

let(variable1 = value1)
let(variable2 = value2)
let(variable3 = value3)
let(...)
expr;
* The syntax was chosen in preference of other alternatives such as c-style comma expression: `var1=val1, var2=val2, ..., expr`, for being clearer, and e.g. curly-braces imperative style syntax `{var1=val1; var2=val2; ...; return expr; }` for being more in line with the everything-is-an-expression context which functions represent in OpenSCAD.
* The syntax is also consistent with the list comprehension syntax proposed in issue #TBA.