E.g. in a function like this:
yard(x) = x * 25.4 * 12 * 3;
Does each call do one multiplication or three?
When I took my compiler writing course in 1968, this was considered a simple and easy optimization. Since OpenSCAD is built on long existing tools, I’d be very surprised if there are 3 multiplications.
-Bob
Tucson AZ
On Feb 5, 2024, at 16:01, nop head via Discuss discuss@lists.openscad.org wrote:
E.g. in a function like this:
yard(x) = x * 25.4 * 12 * 3;
Does each call do one multiplication or three?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
There's no constant folding optimization. Every operator is evaluated
individually during execution, including within functions and loops.
There is no memoization of results (ala Haskell) -- even though there is
caching of computed graphical objects.
I wonder if it's actually worth further optimizing the OpenSCAD
functional language, when migration to Python OpenSCAD is a powerful
solution that's looking pretty promising.
Regards,
Curt
On 2/5/24 15:01, nop head via Discuss wrote:
E.g. in a function like this:
yard(x) = x * 25.4 * 12 * 3;
Does each call do one multiplication or three?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Do note that the slowness in the evaluator is not only caused by the
lack of constant folding, but due to AST walking + passing parameters in
a hash table. I have sscad that tries to rewrite the entire thing from
parser to evaluation, will get back to it when I have more time.
On 6/2/2024 13:27, Curt McDowell via Discuss wrote:
There's no constant folding optimization. Every operator is evaluated
individually during execution, including within functions and loops.
There is no memoization of results (ala Haskell) -- even though there is
caching of computed graphical objects.
I wonder if it's actually worth further optimizing the OpenSCAD
functional language, when migration to Python OpenSCAD is a powerful
solution that's looking pretty promising.
Regards,
Curt
On 2/5/24 15:01, nop head via Discuss wrote:
E.g. in a function like this:
yard(x) = x * 25.4 * 12 * 3;Does each call do one multiplication or three?
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 06.02.24 06:27, Curt McDowell via Discuss wrote:
I wonder if it's actually worth further optimizing the OpenSCAD
functional language, when migration to Python OpenSCAD is a powerful
solution that's looking pretty promising.
In my view Python can be a very useful addition, but it's far from
being a full replacement for all use cases.
ciao,
Torsten.