discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

avoiding geometry recalculation

RW
Rogier Wolff
Tue, Jan 27, 2026 8:18 AM

On 1/25/26 19:51, Jordan Brown via Discuss wrote:

Unfortunately, not perfectly amenable.

There are global-ish variables (both normal variables and $ variables),
plus the rands() function, that can throw a spanner in the works.
function f() = rands(0,1,1)[0];

But variables.... in openscad, can they change?

Yes, rands is a problem. $t too. So still you'd need to tag functions
(bottom up) as valid for caching or not. Calling a function that
isn't already defined is an error, right? Or just assume
"not cachable" for not yet (fully) defined functions.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Verl. Spiegelmakerstraat 37 2645 LZ  Delfgauw, The Netherlands.
** KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a** is going up.  -- Chris Hadfield about flying up the space shuttle.
**  'a' for accelleration.

> On 1/25/26 19:51, Jordan Brown via Discuss wrote: > > Unfortunately, not *perfectly* amenable. > > > > There are global-ish variables (both normal variables and $ variables), > > plus the rands() function, that can throw a spanner in the works. > > function f() = rands(0,1,1)[0]; But variables.... in openscad, can they change? Yes, rands is a problem. $t too. So still you'd need to tag functions (bottom up) as valid for caching or not. Calling a function that isn't already defined is an error, right? Or just assume "not cachable" for not yet (fully) defined functions. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Verl. Spiegelmakerstraat 37 2645 LZ Delfgauw, The Netherlands. ** KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a** is going up. -- Chris Hadfield about flying up the space shuttle. ** 'a' for accelleration.
JB
Jordan Brown
Tue, Jan 27, 2026 9:18 AM

On 1/27/2026 12:18 AM, Rogier Wolff via Discuss wrote:

Unfortunately, not perfectly amenable.

There are global-ish variables (both normal variables and $ variables),
plus the rands() function, that can throw a spanner in the works.

But variables.... in openscad, can they change?

No.  Or at least not exactly.  But a new instance of a scope may have a
different value for a variable, as in this example:

module m(arg) {
    function h() = arg;
    ...
}

And similarly, a function might depend on a $ variable, and you might
call it from different places with different values  for that $ variable.

On 1/27/2026 12:18 AM, Rogier Wolff via Discuss wrote: >>> Unfortunately, not *perfectly* amenable. >>> >>> There are global-ish variables (both normal variables and $ variables), >>> plus the rands() function, that can throw a spanner in the works. > But variables.... in openscad, can they change? No.  Or at least not exactly.  But a new instance of a scope may have a different value for a variable, as in this example: module m(arg) { function h() = arg; ... } And similarly, a function might depend on a $ variable, and you might call it from different places with different values  for that $ variable.