[OpenSCAD] Programming in Functional OpenSCAD

doug moen doug at moens.org
Tue Jan 30 18:16:02 EST 2018

OpenSCAD uses references to reference-counted, immutable values. Multiple
variables can point to the same immutable list object. There is no need for
OpenSCAD to make copies of lists, since there are no operations for
mutating a list. AFAIK; I haven't read all the code in the interpreter.

I don't think there's much point in worrying about this, though. Like
Ronaldo says, just use the simplest possible data structure. If this leads
to a performance problem, and you want to use a more complicated data
structure, you should measure the performance to ensure that the more
complicated code is actually faster. OpenSCAD doesn't have the same
performance characteristics as conventional languages, so your complicated
code might be slower.

On 30 January 2018 at 18:05, NateTG <nate-openscadforum at pedantic.org> wrote:

> > ... For instance, the element insertion and re​moving from  2-3 trees
> have
> order O(log n). However, an analysis of your implementation in OpenSCAD
> will
> show that its order of complexity is O(n2) or worst due to the repeated
> structure copies required by  any change in it.  ...
> Does OpenSCAD never use references (so that if there's some variable a,
> then
> b=[a] is going to create a copy of it)?
> --
> Sent from: http://forum.openscad.org/
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180130/b722f3a6/attachment-0002.html>

More information about the Discuss mailing list