I would call this a bug. Empty for loops are important for handling base
cases and degenerate cases elegantly. This change reminds me of the worst
language I've ever used, IDL, where every base case needs special handling
because something always goes wrong. (IDL had no empty list, so it would
return -1 instead of a list for "empty" for example.)
So examples of OpenSCAD code that didn't give warnings before but does now:
x = [for(i=[0:1:-1]) i];
x = [for(i=[0:-1:1]) i];
These constructions are not wrong and should not produce warnings.
--
Sent from: http://forum.openscad.org/
The idiom for (i = [0:1:len(list)-1])
is used all the time. For an empty list, that translates to for (i=[0:1:-1])
which doesn’t run. And that’s exactly how it is supposed to work. Making it spit out a warning makes “stop on first warning” practically useless for a whole lot of my code. Hell, the entire reason I started putting in the :1: in the middle of ranges was so it would NOT throw deprecation warnings and (iterate backwards).
This is DEFINITELY a bug.
On Dec 25, 2020, at 4:19 PM, adrianv avm4@cornell.edu wrote:
I would call this a bug. Empty for loops are important for handling base
cases and degenerate cases elegantly. This change reminds me of the worst
language I've ever used, IDL, where every base case needs special handling
because something always goes wrong. (IDL had no empty list, so it would
return -1 instead of a list for "empty" for example.)
So examples of OpenSCAD code that didn't give warnings before but does now:
x = [for(i=[0:1:-1]) i];
x = [for(i=[0:-1:1]) i];
These constructions are not wrong and should not produce warnings.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I'm fairly certain that warning only shows if the range is composed
entirely of literal values and no other expressions or variables.
In that case where the user typed all literal values, I think
it's reasonable to assume it was done in error.
So, the following does NOT actually generate any warnings if you test it:
a = [];
b = -1;
x = [for(i=[0:1:len(a)-1]) i];
y = [for(i=[0:b:1]) i];
On Fri, Dec 25, 2020 at 7:03 PM Revar Desmera revarbat@gmail.com wrote:
The idiom for (i = [0:1:len(list)-1])
is used all the time. For an
empty list, that translates to for (i=[0:1:-1])
which doesn’t run. And
that’s exactly how it is supposed to work. Making it spit out a warning
makes “stop on first warning” practically useless for a whole lot of my
code. Hell, the entire reason I started putting in the :1: in the middle
of ranges was so it would NOT throw deprecation warnings and (iterate
backwards).
This is DEFINITELY a bug.
On Dec 25, 2020, at 4:19 PM, adrianv avm4@cornell.edu wrote:
I would call this a bug. Empty for loops are important for handling base
cases and degenerate cases elegantly. This change reminds me of the
worst
language I've ever used, IDL, where every base case needs special
handling
because something always goes wrong. (IDL had no empty list, so it would
return -1 instead of a list for "empty" for example.)
So examples of OpenSCAD code that didn't give warnings before but does
now:
x = [for(i=[0:1:-1]) i];
x = [for(i=[0:-1:1]) i];
These constructions are not wrong and should not produce warnings.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You must be right about this. I've been trying to understand why I am not
getting the warning in our regression tests, which I was pretty sure hit the
zero length case, and this answers that question.
thehans wrote
I'm fairly certain that warning only shows if the range is composed
entirely of literal values and no other expressions or variables.
In that case where the user typed all literal values, I think
it's reasonable to assume it was done in error.
So, the following does NOT actually generate any warnings if you test it:
a = [];
b = -1;
x = [for(i=[0:1:len(a)-1]) i];
y = [for(i=[0:b:1]) i];
On Fri, Dec 25, 2020 at 7:03 PM Revar Desmera <
revarbat@
> wrote:
The idiom for (i = [0:1:len(list)-1])
is used all the time. For an
empty list, that translates to for (i=[0:1:-1])
which doesn’t run. And
that’s exactly how it is supposed to work. Making it spit out a warning
makes “stop on first warning” practically useless for a whole lot of my
code. Hell, the entire reason I started putting in the :1: in the middle
of ranges was so it would NOT throw deprecation warnings and (iterate
backwards).
This is DEFINITELY a bug.
On Dec 25, 2020, at 4:19 PM, adrianv <
avm4@
> wrote:
I would call this a bug. Empty for loops are important for handling
base
cases and degenerate cases elegantly. This change reminds me of the
worst
language I've ever used, IDL, where every base case needs special
handling
because something always goes wrong. (IDL had no empty list, so it
would
return -1 instead of a list for "empty" for example.)
So examples of OpenSCAD code that didn't give warnings before but does
now:
x = [for(i=[0:1:-1]) i];
x = [for(i=[0:-1:1]) i];
These constructions are not wrong and should not produce warnings.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@.openscad
Discuss@.openscad
Discuss@.openscad
--
Sent from: http://forum.openscad.org/