discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

lists/vectors

RW
Raymond West
Sun, Jan 12, 2025 5:07 PM

I'm in the midst of trying to write a simulation, and need to modify
some values in a vector. I came across this, (in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors)
since concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of
OpenSCAD as at May 23 2022. At that date, running the above example
causes the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten
in file Untitled, line 3
<https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1>
Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly
different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file
untitled.scad, line 3
<https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>"


Is this going to continue to flip back and forth every couple of
years? I was going to request it could be as prior to 2022, but it
seems it has been changed, anyway. (my version is 2024.12.03, so I
guess if I update it I can get concat to operate as below.

a=concat(a,b);

Best wishes,

  Ray
I'm in the midst of trying to write a simulation, and need to modify some values in a vector. I came across this, (in https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since concat was not behaving as it should, imnsho. "The preceding description appears to differ from the behaviour of OpenSCAD as at May 23 2022. At that date, running the above example causes the following output: WARNING: a was assigned on line 1 of "Untitled" but was overwritten in file Untitled, line 3 <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> Execution aborted Currently, at least as of version 2025.01.04, the warning is slightly different and does *not* result in an execution abort. WARNING: a was assigned on line 1 but was overwritten in file untitled.scad, line 3 <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>" Is this going to continue to flip back and forth every couple of years? I was going to request it could be as prior to 2022, but it seems it has been changed, anyway. (my version is 2024.12.03, so I guess if I update it I can get concat to operate as below. a=concat(a,b); Best wishes,  Ray
MK
Marius Kintel
Sun, Jan 12, 2025 5:34 PM

This text is wrong - it seems to have been added by an external contributor not familiar with OpenSCAD warnings.

The difference is that in the first instance, “stop on the first warning” was enabled, and in the second it was disabled.

The actual text did change recently, but that change was limited to the wording of the warning itself.

If someone here is a Wikibooks reviewer/admin, perhaps they could roll back that last entry?

-Marius

On Jan 12, 2025, at 12:07, Raymond West via Discuss discuss@lists.openscad.org wrote:

I'm in the midst of trying to write a simulation, and need to modify some values in a vector. I came across this, (in https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of OpenSCAD as at May 23 2022. At that date, running the above example causes the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten in file Untitled, line 3 https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1 Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file untitled.scad, line 3 https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1"

Is this going to continue to flip back and forth every couple of years? I was going to request it could be as prior to 2022, but it seems it has been changed, anyway. (my version is 2024.12.03, so I guess if I update it I can get concat to operate as below.

a=concat(a,b);

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

This text is wrong - it seems to have been added by an external contributor not familiar with OpenSCAD warnings. The difference is that in the first instance, “stop on the first warning” was enabled, and in the second it was disabled. The actual text did change recently, but that change was limited to the wording of the warning itself. If someone here is a Wikibooks reviewer/admin, perhaps they could roll back that last entry? -Marius > On Jan 12, 2025, at 12:07, Raymond West via Discuss <discuss@lists.openscad.org> wrote: > > I'm in the midst of trying to write a simulation, and need to modify some values in a vector. I came across this, (in https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since concat was not behaving as it should, imnsho. > > "The preceding description appears to differ from the behaviour of OpenSCAD as at May 23 2022. At that date, running the above example causes the following output: > > WARNING: a was assigned on line 1 of "Untitled" but was overwritten in file Untitled, line 3 <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> Execution aborted > > Currently, at least as of version 2025.01.04, the warning is slightly different and does not result in an execution abort. > > WARNING: a was assigned on line 1 but was overwritten in file untitled.scad, line 3 <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>" > > > > Is this going to continue to flip back and forth every couple of years? I was going to request it could be as prior to 2022, but it seems it has been changed, anyway. (my version is 2024.12.03, so I guess if I update it I can get concat to operate as below. > > a=concat(a,b); > > Best wishes, > > Ray > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
AM
Adrian Mariano
Sun, Jan 12, 2025 5:58 PM

Ray, I'm a little confused.  You want to be able to write

a = concat(a,b)?

This is obviously not valid (unless the two a values are in different
scopes) because you are re-assigning a, which isn't allowed in OpenSCAD.
It has nothing to do with concat.  You can never modify values of something
in OpenSCAD.

On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

I'm in the midst of trying to write a simulation, and need to modify some
values in a vector. I came across this, (in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since
concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of
OpenSCAD as at May 23 2022. At that date, running the above example causes
the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten in
file Untitled, line 3
https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1
Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly
different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file
untitled.scad, line 3
https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1
"

Is this going to continue to flip back and forth every couple of years? I
was going to request it could be as prior to 2022, but it seems it has been
changed, anyway. (my version is 2024.12.03, so I guess if I update it I can
get concat to operate as below.

a=concat(a,b);

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Ray, I'm a little confused. You want to be able to write a = concat(a,b)? This is obviously not valid (unless the two a values are in different scopes) because you are re-assigning a, which isn't allowed in OpenSCAD. It has nothing to do with concat. You can never modify values of something in OpenSCAD. On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss < discuss@lists.openscad.org> wrote: > I'm in the midst of trying to write a simulation, and need to modify some > values in a vector. I came across this, (in > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since > concat was not behaving as it should, imnsho. > > "The preceding description appears to differ from the behaviour of > OpenSCAD as at May 23 2022. At that date, running the above example causes > the following output: > > WARNING: a was assigned on line 1 of "Untitled" but was overwritten in > file Untitled, line 3 > <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> > Execution aborted > > Currently, at least as of version 2025.01.04, the warning is slightly > different and does *not* result in an execution abort. > > WARNING: a was assigned on line 1 but was overwritten in file > untitled.scad, line 3 > <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1> > " > > > Is this going to continue to flip back and forth every couple of years? I > was going to request it could be as prior to 2022, but it seems it has been > changed, anyway. (my version is 2024.12.03, so I guess if I update it I can > get concat to operate as below. > > a=concat(a,b); > > Best wishes, > > Ray > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
ME
Mark Erbaugh
Sun, Jan 12, 2025 6:30 PM

OpenSCAD uses a different programming paradigm than many other languages. Once assigned “variables” can’t be changed. That includes modifying array or vector elements. That’s a feature of functional programming.

One way to deal with the inability of changing variables is to use recursion. See some of the examples on the  OpenSCAD User Manual/Tips and Tricks page:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks

Mark

On Jan 12, 2025, at 12:58 PM, Adrian Mariano via Discuss discuss@lists.openscad.org wrote:

Ray, I'm a little confused.  You want to be able to write

a = concat(a,b)?

This is obviously not valid (unless the two a values are in different scopes) because you are re-assigning a, which isn't allowed in OpenSCAD.  It has nothing to do with concat.  You can never modify values of something in OpenSCAD.

On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

I'm in the midst of trying to write a simulation, and need to modify some values in a vector. I came across this, (in https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of OpenSCAD as at May 23 2022. At that date, running the above example causes the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten in file Untitled, line 3 https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1 Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file untitled.scad, line 3 https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1"

Is this going to continue to flip back and forth every couple of years? I was going to request it could be as prior to 2022, but it seems it has been changed, anyway. (my version is 2024.12.03, so I guess if I update it I can get concat to operate as below.

a=concat(a,b);

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

OpenSCAD uses a different programming paradigm than many other languages. Once assigned “variables” can’t be changed. That includes modifying array or vector elements. That’s a feature of functional programming. One way to deal with the inability of changing variables is to use recursion. See some of the examples on the OpenSCAD User Manual/Tips and Tricks page: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks Mark > On Jan 12, 2025, at 12:58 PM, Adrian Mariano via Discuss <discuss@lists.openscad.org> wrote: > > Ray, I'm a little confused. You want to be able to write > > a = concat(a,b)? > > This is obviously not valid (unless the two a values are in different scopes) because you are re-assigning a, which isn't allowed in OpenSCAD. It has nothing to do with concat. You can never modify values of something in OpenSCAD. > > On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> I'm in the midst of trying to write a simulation, and need to modify some values in a vector. I came across this, (in https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) since concat was not behaving as it should, imnsho. >> >> "The preceding description appears to differ from the behaviour of OpenSCAD as at May 23 2022. At that date, running the above example causes the following output: >> >> WARNING: a was assigned on line 1 of "Untitled" but was overwritten in file Untitled, line 3 <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> Execution aborted >> >> Currently, at least as of version 2025.01.04, the warning is slightly different and does not result in an execution abort. >> >> WARNING: a was assigned on line 1 but was overwritten in file untitled.scad, line 3 <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>" >> >> >> >> Is this going to continue to flip back and forth every couple of years? I was going to request it could be as prior to 2022, but it seems it has been changed, anyway. (my version is 2024.12.03, so I guess if I update it I can get concat to operate as below. >> >> a=concat(a,b); >> >> Best wishes, >> >> Ray >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RW
Raymond West
Sun, Jan 12, 2025 6:38 PM

Hi Adrian, I'm confused, too. I always thought that variables were
immutable, but the documentation I saw, looked as if you could have

something like a=10; a=20; and it would compile with a =20;

I'm trying to alter values in a grid, and getting stuck, unless I create
a grid with a new name each time a value changes.

The vector population is sparse, but that makes no difference e.g. say
grid[[10,10,6],[67,12,4], [10,18,9]];  and I want to insert a value of
4, say, at location 8,7, to give grid[[10,10,6],[67,12,4],
[10,18,9],[8,7,4]];  (and many other times, too, calling it grid2,
grid3, etc. is not much use) so that later on (all programmatically) It
can act on the last value in a specific x.y. location.  I guess openscad
is not built that way.

On 12/01/2025 17:58, Adrian Mariano via Discuss wrote:

Ray, I'm a little confused.  You want to be able to write

a = concat(a,b)?

This is obviously not valid (unless the two a values are in different
scopes) because you are re-assigning a, which isn't allowed in
OpenSCAD.  It has nothing to do with concat.  You can never modify
values of something in OpenSCAD.

On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss
discuss@lists.openscad.org wrote:

 I'm in the midst of trying to write a simulation, and need to
 modify some values in a vector. I came across this, (in
 https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors)
 since concat was not behaving as it should, imnsho.

 "The preceding description appears to differ from the behaviour of
 OpenSCAD as at May 23 2022. At that date, running the above
 example causes the following output:

     WARNING: a was assigned on line 1 of "Untitled" but was
     overwritten in file Untitled, line 3
     <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1>
     Execution aborted

 Currently, at least as of version 2025.01.04, the warning is
 slightly different and does *not* result in an execution abort.

     WARNING: a was assigned on line 1 but was overwritten in file
     untitled.scad, line 3
     <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>"


     Is this going to continue to flip back and forth every couple
     of years? I was going to request it could be as prior to 2022,
     but it seems it has been changed, anyway. (my version is
     2024.12.03, so I guess if I update it I can get concat to
     operate as below.

     a=concat(a,b);

     Best wishes,

      Ray

 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

Hi Adrian, I'm confused, too. I always thought that variables were immutable, but the documentation I saw, looked as if you could have something like a=10; a=20; and it would compile with a =20; I'm trying to alter values in a grid, and getting stuck, unless I create a grid with a new name each time a value changes. The vector population is sparse, but that makes no difference e.g. say grid[[10,10,6],[67,12,4], [10,18,9]];  and I want to insert a value of 4, say, at location 8,7, to give grid[[10,10,6],[67,12,4], [10,18,9],[8,7,4]];  (and many other times, too, calling it grid2, grid3, etc. is not much use) so that later on (all programmatically) It can act on the last value in a specific x.y. location.  I guess openscad is not built that way. On 12/01/2025 17:58, Adrian Mariano via Discuss wrote: > Ray, I'm a little confused.  You want to be able to write > > a = concat(a,b)? > > This is obviously not valid (unless the two a values are in different > scopes) because you are re-assigning a, which isn't allowed in > OpenSCAD.  It has nothing to do with concat.  You can never modify > values of something in OpenSCAD. > > On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss > <discuss@lists.openscad.org> wrote: > > I'm in the midst of trying to write a simulation, and need to > modify some values in a vector. I came across this, (in > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) > since concat was not behaving as it should, imnsho. > > "The preceding description appears to differ from the behaviour of > OpenSCAD as at May 23 2022. At that date, running the above > example causes the following output: > > WARNING: a was assigned on line 1 of "Untitled" but was > overwritten in file Untitled, line 3 > <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> > Execution aborted > > Currently, at least as of version 2025.01.04, the warning is > slightly different and does *not* result in an execution abort. > > WARNING: a was assigned on line 1 but was overwritten in file > untitled.scad, line 3 > <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>" > > > Is this going to continue to flip back and forth every couple > of years? I was going to request it could be as prior to 2022, > but it seems it has been changed, anyway. (my version is > 2024.12.03, so I guess if I update it I can get concat to > operate as below. > > a=concat(a,b); > > Best wishes, > >  Ray > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
FH
Father Horton
Sun, Jan 12, 2025 6:58 PM

They are immutable. The last definition of a variable in a scope is the one
that counts.

On Sun, Jan 12, 2025 at 12:39 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

Hi Adrian, I'm confused, too. I always thought that variables were
immutable, but the documentation I saw, looked as if you could have

something like a=10; a=20; and it would compile with a =20;

I'm trying to alter values in a grid, and getting stuck, unless I create a
grid with a new name each time a value changes.

The vector population is sparse, but that makes no difference e.g. say
grid[[10,10,6],[67,12,4], [10,18,9]];  and I want to insert a value of 4,
say, at location 8,7, to give grid[[10,10,6],[67,12,4],
[10,18,9],[8,7,4]];  (and many other times, too, calling it grid2, grid3,
etc. is not much use) so that later on (all programmatically) It can act on
the last value in a specific x.y. location.  I guess openscad is not built
that way.

On 12/01/2025 17:58, Adrian Mariano via Discuss wrote:

Ray, I'm a little confused.  You want to be able to write

a = concat(a,b)?

This is obviously not valid (unless the two a values are in different
scopes) because you are re-assigning a, which isn't allowed in OpenSCAD.
It has nothing to do with concat.  You can never modify values of something
in OpenSCAD.

On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

I'm in the midst of trying to write a simulation, and need to modify some
values in a vector. I came across this, (in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors)
since concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of
OpenSCAD as at May 23 2022. At that date, running the above example causes
the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten in
file Untitled, line 3
https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1
Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly
different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file
untitled.scad, line 3
https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1
"

Is this going to continue to flip back and forth every couple of years? I
was going to request it could be as prior to 2022, but it seems it has been
changed, anyway. (my version is 2024.12.03, so I guess if I update it I can
get concat to operate as below.

a=concat(a,b);

Best wishes,

Ray


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


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

They are immutable. The last definition of a variable in a scope is the one that counts. On Sun, Jan 12, 2025 at 12:39 PM Raymond West via Discuss < discuss@lists.openscad.org> wrote: > Hi Adrian, I'm confused, too. I always thought that variables were > immutable, but the documentation I saw, looked as if you could have > > something like a=10; a=20; and it would compile with a =20; > > I'm trying to alter values in a grid, and getting stuck, unless I create a > grid with a new name each time a value changes. > > The vector population is sparse, but that makes no difference e.g. say > grid[[10,10,6],[67,12,4], [10,18,9]]; and I want to insert a value of 4, > say, at location 8,7, to give grid[[10,10,6],[67,12,4], > [10,18,9],[8,7,4]]; (and many other times, too, calling it grid2, grid3, > etc. is not much use) so that later on (all programmatically) It can act on > the last value in a specific x.y. location. I guess openscad is not built > that way. > > > On 12/01/2025 17:58, Adrian Mariano via Discuss wrote: > > Ray, I'm a little confused. You want to be able to write > > a = concat(a,b)? > > This is obviously not valid (unless the two a values are in different > scopes) because you are re-assigning a, which isn't allowed in OpenSCAD. > It has nothing to do with concat. You can never modify values of something > in OpenSCAD. > > On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss < > discuss@lists.openscad.org> wrote: > >> I'm in the midst of trying to write a simulation, and need to modify some >> values in a vector. I came across this, (in >> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) >> since concat was not behaving as it should, imnsho. >> >> "The preceding description appears to differ from the behaviour of >> OpenSCAD as at May 23 2022. At that date, running the above example causes >> the following output: >> >> WARNING: a was assigned on line 1 of "Untitled" but was overwritten in >> file Untitled, line 3 >> <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> >> Execution aborted >> >> Currently, at least as of version 2025.01.04, the warning is slightly >> different and does *not* result in an execution abort. >> >> WARNING: a was assigned on line 1 but was overwritten in file >> untitled.scad, line 3 >> <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1> >> " >> >> >> Is this going to continue to flip back and forth every couple of years? I >> was going to request it could be as prior to 2022, but it seems it has been >> changed, anyway. (my version is 2024.12.03, so I guess if I update it I can >> get concat to operate as below. >> >> a=concat(a,b); >> >> Best wishes, >> >> Ray >> >> _______________________________________________ >> 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 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Sun, Jan 12, 2025 7:34 PM

Ray, if you cannot construct your data structure all at once somehow with a
list comprehension, then you need to do it using recursion, or you can use
the C-style list comprehension, which in my experience is usually harder to
use than recursion, but may possibly run faster.

In many cases it is possible to use a list comprehension to make your data
structure, as long as the points on your grid do not depend on previous
points, but when points depend on previous points, this is impossible.

On Sun, Jan 12, 2025 at 1:42 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

Hi Adrian, I'm confused, too. I always thought that variables were
immutable, but the documentation I saw, looked as if you could have

something like a=10; a=20; and it would compile with a =20;

I'm trying to alter values in a grid, and getting stuck, unless I create a
grid with a new name each time a value changes.

The vector population is sparse, but that makes no difference e.g. say
grid[[10,10,6],[67,12,4], [10,18,9]];  and I want to insert a value of 4,
say, at location 8,7, to give grid[[10,10,6],[67,12,4],
[10,18,9],[8,7,4]];  (and many other times, too, calling it grid2, grid3,
etc. is not much use) so that later on (all programmatically) It can act on
the last value in a specific x.y. location.  I guess openscad is not built
that way.

On 12/01/2025 17:58, Adrian Mariano via Discuss wrote:

Ray, I'm a little confused.  You want to be able to write

a = concat(a,b)?

This is obviously not valid (unless the two a values are in different
scopes) because you are re-assigning a, which isn't allowed in OpenSCAD.
It has nothing to do with concat.  You can never modify values of something
in OpenSCAD.

On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

I'm in the midst of trying to write a simulation, and need to modify some
values in a vector. I came across this, (in
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors)
since concat was not behaving as it should, imnsho.

"The preceding description appears to differ from the behaviour of
OpenSCAD as at May 23 2022. At that date, running the above example causes
the following output:

WARNING: a was assigned on line 1 of "Untitled" but was overwritten in
file Untitled, line 3
https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1
Execution aborted

Currently, at least as of version 2025.01.04, the warning is slightly
different and does not result in an execution abort.

WARNING: a was assigned on line 1 but was overwritten in file
untitled.scad, line 3
https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1
"

Is this going to continue to flip back and forth every couple of years? I
was going to request it could be as prior to 2022, but it seems it has been
changed, anyway. (my version is 2024.12.03, so I guess if I update it I can
get concat to operate as below.

a=concat(a,b);

Best wishes,

Ray


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


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Ray, if you cannot construct your data structure all at once somehow with a list comprehension, then you need to do it using recursion, or you can use the C-style list comprehension, which in my experience is usually harder to use than recursion, but may possibly run faster. In many cases it is possible to use a list comprehension to make your data structure, as long as the points on your grid do not depend on previous points, but when points depend on previous points, this is impossible. On Sun, Jan 12, 2025 at 1:42 PM Raymond West via Discuss < discuss@lists.openscad.org> wrote: > Hi Adrian, I'm confused, too. I always thought that variables were > immutable, but the documentation I saw, looked as if you could have > > something like a=10; a=20; and it would compile with a =20; > > I'm trying to alter values in a grid, and getting stuck, unless I create a > grid with a new name each time a value changes. > > The vector population is sparse, but that makes no difference e.g. say > grid[[10,10,6],[67,12,4], [10,18,9]]; and I want to insert a value of 4, > say, at location 8,7, to give grid[[10,10,6],[67,12,4], > [10,18,9],[8,7,4]]; (and many other times, too, calling it grid2, grid3, > etc. is not much use) so that later on (all programmatically) It can act on > the last value in a specific x.y. location. I guess openscad is not built > that way. > > > On 12/01/2025 17:58, Adrian Mariano via Discuss wrote: > > Ray, I'm a little confused. You want to be able to write > > a = concat(a,b)? > > This is obviously not valid (unless the two a values are in different > scopes) because you are re-assigning a, which isn't allowed in OpenSCAD. > It has nothing to do with concat. You can never modify values of something > in OpenSCAD. > > On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss < > discuss@lists.openscad.org> wrote: > >> I'm in the midst of trying to write a simulation, and need to modify some >> values in a vector. I came across this, (in >> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) >> since concat was not behaving as it should, imnsho. >> >> "The preceding description appears to differ from the behaviour of >> OpenSCAD as at May 23 2022. At that date, running the above example causes >> the following output: >> >> WARNING: a was assigned on line 1 of "Untitled" but was overwritten in >> file Untitled, line 3 >> <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> >> Execution aborted >> >> Currently, at least as of version 2025.01.04, the warning is slightly >> different and does *not* result in an execution abort. >> >> WARNING: a was assigned on line 1 but was overwritten in file >> untitled.scad, line 3 >> <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1> >> " >> >> >> Is this going to continue to flip back and forth every couple of years? I >> was going to request it could be as prior to 2022, but it seems it has been >> changed, anyway. (my version is 2024.12.03, so I guess if I update it I can >> get concat to operate as below. >> >> a=concat(a,b); >> >> Best wishes, >> >> Ray >> >> _______________________________________________ >> 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 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Raymond West
Sun, Jan 12, 2025 8:27 PM

What I would like to do, is most likely impossible in raw openscad, but
I think I may be able to fudge it, by saving the points and values as a
dxf file, and re-import when I next run it. dxf is not ideal, but SVG is
easier, but I've not recently looked in how to get the values I need. In
some ways it is a shame that we can't programmatically save and read
plain text files, as  that would make it simple to print out a parts
list, assembly instructions/whatever. But, I guess we need to keep
openscad pure...

I am only trying to replicate a piece of software that I wrote years
ago, just as a mental challenge. It would be easy in Python, Basic, C#
or whatever, but that is not the challenge for me.  I think a simple
method, if i restrict it to ten changes of values in a grid, say 100 by
100, would be to create ten individually named lists and sort of use
brute force, but that may not be enough resolution for what I want to show.

I obviously misinterpreted the recent message in the wikibooks, but, I
find in general the documentation is often quite confusing.

On 12/01/2025 19:34, Adrian Mariano via Discuss wrote:

Ray, if you cannot construct your data structure all at once somehow
with a list comprehension, then you need to do it using recursion, or
you can use the C-style list comprehension, which in my experience is
usually harder to use than recursion, but may possibly run faster.

In many cases it is possible to use a list comprehension to make your
data structure, as long as the points on your grid do not depend on
previous points, but when points depend on previous points, this is
impossible.

On Sun, Jan 12, 2025 at 1:42 PM Raymond West via Discuss
discuss@lists.openscad.org wrote:

 Hi Adrian, I'm confused, too. I always thought that variables were
 immutable, but the documentation I saw, looked as if you could have

 something like a=10; a=20; and it would compile with a =20;

 I'm trying to alter values in a grid, and getting stuck, unless I
 create a grid with a new name each time a value changes.

 The vector population is sparse, but that makes no difference e.g.
 say grid[[10,10,6],[67,12,4], [10,18,9]]; and I want to insert a
 value of 4, say, at location 8,7, to give
 grid[[10,10,6],[67,12,4], [10,18,9],[8,7,4]]; (and many other
 times, too, calling it grid2, grid3, etc. is not much use) so that
 later on (all programmatically) It can act on the last value in a
 specific x.y. location. I guess openscad is not built that way.


 On 12/01/2025 17:58, Adrian Mariano via Discuss wrote:
 Ray, I'm a little confused.  You want to be able to write

 a = concat(a,b)?

 This is obviously not valid (unless the two a values are in
 different scopes) because you are re-assigning a, which isn't
 allowed in OpenSCAD.  It has nothing to do with concat.  You can
 never modify values of something in OpenSCAD.

 On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss
 <discuss@lists.openscad.org> wrote:

     I'm in the midst of trying to write a simulation, and need to
     modify some values in a vector. I came across this, (in
     https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors)
     since concat was not behaving as it should, imnsho.

     "The preceding description appears to differ from the
     behaviour of OpenSCAD as at May 23 2022. At that date,
     running the above example causes the following output:

         WARNING: a was assigned on line 1 of "Untitled" but was
         overwritten in file Untitled, line 3
         <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1>
         Execution aborted

     Currently, at least as of version 2025.01.04, the warning is
     slightly different and does *not* result in an execution abort.

         WARNING: a was assigned on line 1 but was overwritten in
         file untitled.scad, line 3
         <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>"


         Is this going to continue to flip back and forth every
         couple of years? I was going to request it could be as
         prior to 2022, but it seems it has been changed, anyway.
         (my version is 2024.12.03, so I guess if I update it I
         can get concat to operate as below.

         a=concat(a,b);

         Best wishes,

          Ray

     _______________________________________________
     OpenSCAD mailing list
     To unsubscribe send an email to discuss-leave@lists.openscad.org


 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email todiscuss-leave@lists.openscad.org
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

What I would like to do, is most likely impossible in raw openscad, but I think I may be able to fudge it, by saving the points and values as a dxf file, and re-import when I next run it. dxf is not ideal, but SVG is easier, but I've not recently looked in how to get the values I need. In some ways it is a shame that we can't programmatically save and read plain text files, as  that would make it simple to print out a parts list, assembly instructions/whatever. But, I guess we need to keep openscad pure... I am only trying to replicate a piece of software that I wrote years ago, just as a mental challenge. It would be easy in Python, Basic, C# or whatever, but that is not the challenge for me.  I think a simple method, if i restrict it to ten changes of values in a grid, say 100 by 100, would be to create ten individually named lists and sort of use brute force, but that may not be enough resolution for what I want to show. I obviously misinterpreted the recent message in the wikibooks, but, I find in general the documentation is often quite confusing. On 12/01/2025 19:34, Adrian Mariano via Discuss wrote: > Ray, if you cannot construct your data structure all at once somehow > with a list comprehension, then you need to do it using recursion, or > you can use the C-style list comprehension, which in my experience is > usually harder to use than recursion, but may possibly run faster. > > In many cases it is possible to use a list comprehension to make your > data structure, as long as the points on your grid do not depend on > previous points, but when points depend on previous points, this is > impossible. > > On Sun, Jan 12, 2025 at 1:42 PM Raymond West via Discuss > <discuss@lists.openscad.org> wrote: > > Hi Adrian, I'm confused, too. I always thought that variables were > immutable, but the documentation I saw, looked as if you could have > > something like a=10; a=20; and it would compile with a =20; > > I'm trying to alter values in a grid, and getting stuck, unless I > create a grid with a new name each time a value changes. > > The vector population is sparse, but that makes no difference e.g. > say grid[[10,10,6],[67,12,4], [10,18,9]]; and I want to insert a > value of 4, say, at location 8,7, to give > grid[[10,10,6],[67,12,4], [10,18,9],[8,7,4]]; (and many other > times, too, calling it grid2, grid3, etc. is not much use) so that > later on (all programmatically) It can act on the last value in a > specific x.y. location. I guess openscad is not built that way. > > > On 12/01/2025 17:58, Adrian Mariano via Discuss wrote: >> Ray, I'm a little confused.  You want to be able to write >> >> a = concat(a,b)? >> >> This is obviously not valid (unless the two a values are in >> different scopes) because you are re-assigning a, which isn't >> allowed in OpenSCAD.  It has nothing to do with concat.  You can >> never modify values of something in OpenSCAD. >> >> On Sun, Jan 12, 2025 at 12:09 PM Raymond West via Discuss >> <discuss@lists.openscad.org> wrote: >> >> I'm in the midst of trying to write a simulation, and need to >> modify some values in a vector. I came across this, (in >> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors) >> since concat was not behaving as it should, imnsho. >> >> "The preceding description appears to differ from the >> behaviour of OpenSCAD as at May 23 2022. At that date, >> running the above example causes the following output: >> >> WARNING: a was assigned on line 1 of "Untitled" but was >> overwritten in file Untitled, line 3 >> <https://en.wikibooks.org/w/index.php?title=3,C:/Program_Files/OpenSCAD/libraries/Helpers&action=edit&redlink=1> >> Execution aborted >> >> Currently, at least as of version 2025.01.04, the warning is >> slightly different and does *not* result in an execution abort. >> >> WARNING: a was assigned on line 1 but was overwritten in >> file untitled.scad, line 3 >> <https://en.wikibooks.org/w/index.php?title=WARNING:_a_was_assigned_on_line_1_but_was_overwritten_in_file_untitled.scad,_line_3&action=edit&redlink=1>" >> >> >> Is this going to continue to flip back and forth every >> couple of years? I was going to request it could be as >> prior to 2022, but it seems it has been changed, anyway. >> (my version is 2024.12.03, so I guess if I update it I >> can get concat to operate as below. >> >> a=concat(a,b); >> >> Best wishes, >> >>  Ray >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
FH
Father Horton
Sun, Jan 12, 2025 10:10 PM

Not to beat a dead horse, but if you run:

a = 10;
echo(a);
a = 20;
echo(a);

You get this:

WARNING: a was assigned on line 1 but was overwritten in file test.scad,
line 3
Compiling design (CSG Tree generation)...
ECHO: 20
ECHO: 20

So it looks like variable a got a new value, but it never did.

Not to beat a dead horse, but if you run: a = 10; echo(a); a = 20; echo(a); You get this: WARNING: a was assigned on line 1 but was overwritten in file test.scad, line 3 Compiling design (CSG Tree generation)... ECHO: 20 ECHO: 20 So it looks like variable a got a new value, but it never did.
RW
Raymond West
Sun, Jan 12, 2025 10:57 PM

that is what I inferred from the description in the wiki, that started
this thread

On 12/01/2025 22:10, Father Horton via Discuss wrote:

So it looks like variable a got a new value

that is what I inferred from the description in the wiki, that started this thread On 12/01/2025 22:10, Father Horton via Discuss wrote: > So it looks like variable a got a new value