DM
doug moen
Sun, Dec 18, 2016 5:37 PM
Hi Parkinbot.
I agree with your point, but there is a bigger issue to consider.
The bug only gets triggered with very special values of step, first and
last.
In most of the forum posts reporting this bug, a step of 0.2 was used,
although Johan discovered it using a step of 1.2.
Even with a special step value, you also need special first/last values.
For example, [1 : 0.2 : 2] works.
[1 : 0.2 : 3] fails, 4 through 8 fail.
But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
Because the bug is difficult to trigger, you could be using OpenSCAD for
a long time without encountering the bug. For example, Johan has been
a forum member for some time, but he is just now reporting the bug.
There are probably a lot of parameterized models out there that
contain the bug, including on Thingiverse, but the author might be
unaware because he didn't test with the magic parameter values that
trigger the bug.
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
and we will also be removing a weird pitfall that OpenSCAD users
continue to trip over and report in the forum.
Doug Moen.
On 18 December 2016 at 07:09, Parkinbot rudolf@parkinbot.com wrote:
Doug,
again a vote for silent behavior and hidden magic - and no means to roll
back. You propose a solution that will potentially break existing code and
algorithms. The semantical difference can be a "hard to spot" problem as
soon as nested loops come into play and can affect each (!) nesting level.
Look at this double loop, (where only the inner loop is effected, as the
outer loop is classical):
first = 6.8;
step = .2;
last = 8;
for (y=[7.4:.05:8.4]) loops(y);
module loops(last)
{
echo(classic = classic_loop(first, step, last));
echo(dougs = doug_loop(first, step, last));
echo();
}
function classic_loop(first, step, last) = [for(x = [first: step: last])
x];
function doug_loop(first, step, last) =
let(first_ = 0)
let(step_ = sign(step))
let(last_ = round((last-first)/step))
[for(i = [first_: step_: last_]) first+i*step];
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
Hi Parkinbot.
I agree with your point, but there is a bigger issue to consider.
The bug only gets triggered with very special values of step, first and
last.
In most of the forum posts reporting this bug, a step of 0.2 was used,
although Johan discovered it using a step of 1.2.
Even with a special step value, you also need special first/last values.
For example, [1 : 0.2 : 2] works.
[1 : 0.2 : 3] fails, 4 through 8 fail.
But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
Because the bug is difficult to trigger, you could be using OpenSCAD for
a long time without encountering the bug. For example, Johan has been
a forum member for some time, but he is just now reporting the bug.
There are probably a lot of parameterized models out there that
contain the bug, including on Thingiverse, but the author might be
unaware because he didn't test with the magic parameter values that
trigger the bug.
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
and we will also be removing a weird pitfall that OpenSCAD users
continue to trip over and report in the forum.
Doug Moen.
On 18 December 2016 at 07:09, Parkinbot <rudolf@parkinbot.com> wrote:
> Doug,
>
> again a vote for silent behavior and hidden magic - and no means to roll
> back. You propose a solution that will potentially break existing code and
> algorithms. The semantical difference can be a "hard to spot" problem as
> soon as nested loops come into play and can affect each (!) nesting level.
>
> Look at this double loop, (where only the inner loop is effected, as the
> outer loop is classical):
>
> > first = 6.8;
> > step = .2;
> > last = 8;
> >
> > for (y=[7.4:.05:8.4]) loops(y);
> >
> > module loops(last)
> > {
> > echo(classic = classic_loop(first, step, last));
> > echo(dougs = doug_loop(first, step, last));
> > echo();
> > }
> >
> > function classic_loop(first, step, last) = [for(x = [first: step: last])
> > x];
> >
> > function doug_loop(first, step, last) =
> > let(first_ = 0)
> > let(step_ = sign(step))
> > let(last_ = round((last-first)/step))
> > [for(i = [first_: step_: last_]) first+i*step];
>
> this is the output:
>
> > ECHO: classic = [6.8, 7, 7.2, 7.4]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
> > ECHO:
> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
> > ECHO:
>
>
>
>
>
> --
> View this message in context: http://forum.openscad.org/for-
> statement-doesn-t-do-all-the-steps-sometimes-tp19591p19622.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
NH
nop head
Sun, Dec 18, 2016 5:56 PM
I don't understand why the last value should equal the limit. What about
[0:2:9]? Surely that should stop at 8.
Perhaps just give a warning if the step is not an integer and deprecate it.
A floating point step is just a bad idea because most fractions are inexact
in binary.
On 18 December 2016 at 17:37, doug moen doug@moens.org wrote:
Hi Parkinbot.
I agree with your point, but there is a bigger issue to consider.
The bug only gets triggered with very special values of step, first and
last.
In most of the forum posts reporting this bug, a step of 0.2 was used,
although Johan discovered it using a step of 1.2.
Even with a special step value, you also need special first/last values.
For example, [1 : 0.2 : 2] works.
[1 : 0.2 : 3] fails, 4 through 8 fail.
But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
Because the bug is difficult to trigger, you could be using OpenSCAD for
a long time without encountering the bug. For example, Johan has been
a forum member for some time, but he is just now reporting the bug.
There are probably a lot of parameterized models out there that
contain the bug, including on Thingiverse, but the author might be
unaware because he didn't test with the magic parameter values that
trigger the bug.
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
and we will also be removing a weird pitfall that OpenSCAD users
continue to trip over and report in the forum.
Doug Moen.
On 18 December 2016 at 07:09, Parkinbot rudolf@parkinbot.com wrote:
Doug,
again a vote for silent behavior and hidden magic - and no means to roll
back. You propose a solution that will potentially break existing code and
algorithms. The semantical difference can be a "hard to spot" problem as
soon as nested loops come into play and can affect each (!) nesting level.
Look at this double loop, (where only the inner loop is effected, as the
outer loop is classical):
first = 6.8;
step = .2;
last = 8;
for (y=[7.4:.05:8.4]) loops(y);
module loops(last)
{
echo(classic = classic_loop(first, step, last));
echo(dougs = doug_loop(first, step, last));
echo();
}
function classic_loop(first, step, last) = [for(x = [first: step: last])
x];
function doug_loop(first, step, last) =
let(first_ = 0)
let(step_ = sign(step))
let(last_ = round((last-first)/step))
[for(i = [first_: step_: last_]) first+i*step];
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
I don't understand why the last value should equal the limit. What about
[0:2:9]? Surely that should stop at 8.
Perhaps just give a warning if the step is not an integer and deprecate it.
A floating point step is just a bad idea because most fractions are inexact
in binary.
On 18 December 2016 at 17:37, doug moen <doug@moens.org> wrote:
> Hi Parkinbot.
>
> I agree with your point, but there is a bigger issue to consider.
>
> The bug only gets triggered with very special values of step, first and
> last.
> In most of the forum posts reporting this bug, a step of 0.2 was used,
> although Johan discovered it using a step of 1.2.
> Even with a special step value, you also need special first/last values.
> For example, [1 : 0.2 : 2] works.
> [1 : 0.2 : 3] fails, 4 through 8 fail.
> But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
>
> Because the bug is difficult to trigger, you could be using OpenSCAD for
> a long time without encountering the bug. For example, Johan has been
> a forum member for some time, but he is just now reporting the bug.
>
> There are probably a lot of parameterized models out there that
> contain the bug, including on Thingiverse, but the author might be
> unaware because he didn't test with the magic parameter values that
> trigger the bug.
>
> If we fix this bug, we will likely be fixing bugs in a lot of existing
> models,
> and we will also be removing a weird pitfall that OpenSCAD users
> continue to trip over and report in the forum.
>
> Doug Moen.
>
>
> On 18 December 2016 at 07:09, Parkinbot <rudolf@parkinbot.com> wrote:
>
>> Doug,
>>
>> again a vote for silent behavior and hidden magic - and no means to roll
>> back. You propose a solution that will potentially break existing code and
>> algorithms. The semantical difference can be a "hard to spot" problem as
>> soon as nested loops come into play and can affect each (!) nesting level.
>>
>> Look at this double loop, (where only the inner loop is effected, as the
>> outer loop is classical):
>>
>> > first = 6.8;
>> > step = .2;
>> > last = 8;
>> >
>> > for (y=[7.4:.05:8.4]) loops(y);
>> >
>> > module loops(last)
>> > {
>> > echo(classic = classic_loop(first, step, last));
>> > echo(dougs = doug_loop(first, step, last));
>> > echo();
>> > }
>> >
>> > function classic_loop(first, step, last) = [for(x = [first: step: last])
>> > x];
>> >
>> > function doug_loop(first, step, last) =
>> > let(first_ = 0)
>> > let(step_ = sign(step))
>> > let(last_ = round((last-first)/step))
>> > [for(i = [first_: step_: last_]) first+i*step];
>>
>> this is the output:
>>
>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>> > ECHO:
>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>> > ECHO:
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://forum.openscad.org/for-
>> statement-doesn-t-do-all-the-steps-sometimes-tp19591p19622.html
>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
JD
Jerry Davis
Sun, Dec 18, 2016 6:15 PM
I did this to come up with the same code doing integer arithmetic:
// your code: for (a7=[ 6.8:1/5:7.8]) echo(A7=a7);
for (a7=[0:2:11]) echo(A7=6.8+a7/10);
Maybe if everyone KNEW what to expect and made the appropriate changes in
their code:
So we change the examples in the Documentation, to reflect what is
happening, and those who don't change their code takes the consequences.
This all blind sided me when I looked at the Documentation.
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".- Isaac. Asimov
On Sun, Dec 18, 2016 at 10:56 AM, nop head nop.head@gmail.com wrote:
I don't understand why the last value should equal the limit. What about
[0:2:9]? Surely that should stop at 8.
Perhaps just give a warning if the step is not an integer and deprecate
it. A floating point step is just a bad idea because most fractions are
inexact in binary.
On 18 December 2016 at 17:37, doug moen doug@moens.org wrote:
Hi Parkinbot.
I agree with your point, but there is a bigger issue to consider.
The bug only gets triggered with very special values of step, first and
last.
In most of the forum posts reporting this bug, a step of 0.2 was used,
although Johan discovered it using a step of 1.2.
Even with a special step value, you also need special first/last values.
For example, [1 : 0.2 : 2] works.
[1 : 0.2 : 3] fails, 4 through 8 fail.
But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
Because the bug is difficult to trigger, you could be using OpenSCAD for
a long time without encountering the bug. For example, Johan has been
a forum member for some time, but he is just now reporting the bug.
There are probably a lot of parameterized models out there that
contain the bug, including on Thingiverse, but the author might be
unaware because he didn't test with the magic parameter values that
trigger the bug.
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
and we will also be removing a weird pitfall that OpenSCAD users
continue to trip over and report in the forum.
Doug Moen.
On 18 December 2016 at 07:09, Parkinbot rudolf@parkinbot.com wrote:
Doug,
again a vote for silent behavior and hidden magic - and no means to roll
back. You propose a solution that will potentially break existing code
and
algorithms. The semantical difference can be a "hard to spot" problem as
soon as nested loops come into play and can affect each (!) nesting
level.
Look at this double loop, (where only the inner loop is effected, as the
outer loop is classical):
first = 6.8;
step = .2;
last = 8;
for (y=[7.4:.05:8.4]) loops(y);
module loops(last)
{
echo(classic = classic_loop(first, step, last));
echo(dougs = doug_loop(first, step, last));
echo();
}
function classic_loop(first, step, last) = [for(x = [first: step:
x];
function doug_loop(first, step, last) =
let(first_ = 0)
let(step_ = sign(step))
let(last_ = round((last-first)/step))
[for(i = [first_: step_: last_]) first+i*step];
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
I did this to come up with the same code doing integer arithmetic:
// your code: for (a7=[ 6.8:1/5:7.8]) echo(A7=a7);
for (a7=[0:2:11]) echo(A7=6.8+a7/10);
Maybe if everyone KNEW what to expect and made the appropriate changes in
their code:
So we change the examples in the Documentation, to reflect what is
happening, and those who don't change their code takes the consequences.
This all blind sided me when I looked at the Documentation.
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
On Sun, Dec 18, 2016 at 10:56 AM, nop head <nop.head@gmail.com> wrote:
> I don't understand why the last value should equal the limit. What about
> [0:2:9]? Surely that should stop at 8.
>
> Perhaps just give a warning if the step is not an integer and deprecate
> it. A floating point step is just a bad idea because most fractions are
> inexact in binary.
>
> On 18 December 2016 at 17:37, doug moen <doug@moens.org> wrote:
>
>> Hi Parkinbot.
>>
>> I agree with your point, but there is a bigger issue to consider.
>>
>> The bug only gets triggered with very special values of step, first and
>> last.
>> In most of the forum posts reporting this bug, a step of 0.2 was used,
>> although Johan discovered it using a step of 1.2.
>> Even with a special step value, you also need special first/last values.
>> For example, [1 : 0.2 : 2] works.
>> [1 : 0.2 : 3] fails, 4 through 8 fail.
>> But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
>>
>> Because the bug is difficult to trigger, you could be using OpenSCAD for
>> a long time without encountering the bug. For example, Johan has been
>> a forum member for some time, but he is just now reporting the bug.
>>
>> There are probably a lot of parameterized models out there that
>> contain the bug, including on Thingiverse, but the author might be
>> unaware because he didn't test with the magic parameter values that
>> trigger the bug.
>>
>> If we fix this bug, we will likely be fixing bugs in a lot of existing
>> models,
>> and we will also be removing a weird pitfall that OpenSCAD users
>> continue to trip over and report in the forum.
>>
>> Doug Moen.
>>
>>
>> On 18 December 2016 at 07:09, Parkinbot <rudolf@parkinbot.com> wrote:
>>
>>> Doug,
>>>
>>> again a vote for silent behavior and hidden magic - and no means to roll
>>> back. You propose a solution that will potentially break existing code
>>> and
>>> algorithms. The semantical difference can be a "hard to spot" problem as
>>> soon as nested loops come into play and can affect each (!) nesting
>>> level.
>>>
>>> Look at this double loop, (where only the inner loop is effected, as the
>>> outer loop is classical):
>>>
>>> > first = 6.8;
>>> > step = .2;
>>> > last = 8;
>>> >
>>> > for (y=[7.4:.05:8.4]) loops(y);
>>> >
>>> > module loops(last)
>>> > {
>>> > echo(classic = classic_loop(first, step, last));
>>> > echo(dougs = doug_loop(first, step, last));
>>> > echo();
>>> > }
>>> >
>>> > function classic_loop(first, step, last) = [for(x = [first: step:
>>> last])
>>> > x];
>>> >
>>> > function doug_loop(first, step, last) =
>>> > let(first_ = 0)
>>> > let(step_ = sign(step))
>>> > let(last_ = round((last-first)/step))
>>> > [for(i = [first_: step_: last_]) first+i*step];
>>>
>>> this is the output:
>>>
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>>> > ECHO:
>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>>> > ECHO:
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://forum.openscad.org/for-
>>> statement-doesn-t-do-all-the-steps-sometimes-tp19591p19622.html
>>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>>>
>>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
JD
Jerry Davis
Sun, Dec 18, 2016 6:28 PM
or more simply:
for (a7=[ 68:2:78]) echo(myA7=a7/10);
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".- Isaac. Asimov
On Sun, Dec 18, 2016 at 11:15 AM, Jerry Davis jdawgaz@gmail.com wrote:
I did this to come up with the same code doing integer arithmetic:
// your code: for (a7=[ 6.8:1/5:7.8]) echo(A7=a7);
for (a7=[0:2:11]) echo(A7=6.8+a7/10);
Maybe if everyone KNEW what to expect and made the appropriate changes in
their code:
So we change the examples in the Documentation, to reflect what is
happening, and those who don't change their code takes the consequences.
This all blind sided me when I looked at the Documentation.
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".- Isaac. Asimov
On Sun, Dec 18, 2016 at 10:56 AM, nop head nop.head@gmail.com wrote:
I don't understand why the last value should equal the limit. What about
[0:2:9]? Surely that should stop at 8.
Perhaps just give a warning if the step is not an integer and deprecate
it. A floating point step is just a bad idea because most fractions are
inexact in binary.
On 18 December 2016 at 17:37, doug moen doug@moens.org wrote:
Hi Parkinbot.
I agree with your point, but there is a bigger issue to consider.
The bug only gets triggered with very special values of step, first and
last.
In most of the forum posts reporting this bug, a step of 0.2 was used,
although Johan discovered it using a step of 1.2.
Even with a special step value, you also need special first/last values.
For example, [1 : 0.2 : 2] works.
[1 : 0.2 : 3] fails, 4 through 8 fail.
But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
Because the bug is difficult to trigger, you could be using OpenSCAD for
a long time without encountering the bug. For example, Johan has been
a forum member for some time, but he is just now reporting the bug.
There are probably a lot of parameterized models out there that
contain the bug, including on Thingiverse, but the author might be
unaware because he didn't test with the magic parameter values that
trigger the bug.
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
and we will also be removing a weird pitfall that OpenSCAD users
continue to trip over and report in the forum.
Doug Moen.
On 18 December 2016 at 07:09, Parkinbot rudolf@parkinbot.com wrote:
Doug,
again a vote for silent behavior and hidden magic - and no means to roll
back. You propose a solution that will potentially break existing code
and
algorithms. The semantical difference can be a "hard to spot" problem as
soon as nested loops come into play and can affect each (!) nesting
level.
Look at this double loop, (where only the inner loop is effected, as the
outer loop is classical):
first = 6.8;
step = .2;
last = 8;
for (y=[7.4:.05:8.4]) loops(y);
module loops(last)
{
echo(classic = classic_loop(first, step, last));
echo(dougs = doug_loop(first, step, last));
echo();
}
function classic_loop(first, step, last) = [for(x = [first: step:
x];
function doug_loop(first, step, last) =
let(first_ = 0)
let(step_ = sign(step))
let(last_ = round((last-first)/step))
[for(i = [first_: step_: last_]) first+i*step];
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
ECHO:
or more simply:
for (a7=[ 68:2:78]) echo(myA7=a7/10);
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
On Sun, Dec 18, 2016 at 11:15 AM, Jerry Davis <jdawgaz@gmail.com> wrote:
> I did this to come up with the same code doing integer arithmetic:
>
> // your code: for (a7=[ 6.8:1/5:7.8]) echo(A7=a7);
>
> for (a7=[0:2:11]) echo(A7=6.8+a7/10);
>
> Maybe if everyone KNEW what to expect and made the appropriate changes in
> their code:
> So we change the examples in the Documentation, to reflect what is
> happening, and those who don't change their code takes the consequences.
> This all blind sided me when I looked at the Documentation.
>
>
>
>
>
> --
> Extra Ham Operator: K7AZJ
> Registered Linux User: 275424
> Raspberry Pi and Openscad developer
>
>
> *The most exciting phrase to hear in science - the one that heralds new
> discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
>
> On Sun, Dec 18, 2016 at 10:56 AM, nop head <nop.head@gmail.com> wrote:
>
>> I don't understand why the last value should equal the limit. What about
>> [0:2:9]? Surely that should stop at 8.
>>
>> Perhaps just give a warning if the step is not an integer and deprecate
>> it. A floating point step is just a bad idea because most fractions are
>> inexact in binary.
>>
>> On 18 December 2016 at 17:37, doug moen <doug@moens.org> wrote:
>>
>>> Hi Parkinbot.
>>>
>>> I agree with your point, but there is a bigger issue to consider.
>>>
>>> The bug only gets triggered with very special values of step, first and
>>> last.
>>> In most of the forum posts reporting this bug, a step of 0.2 was used,
>>> although Johan discovered it using a step of 1.2.
>>> Even with a special step value, you also need special first/last values.
>>> For example, [1 : 0.2 : 2] works.
>>> [1 : 0.2 : 3] fails, 4 through 8 fail.
>>> But [1 : 0.2 : 9] succeeds, and all ints > 9 succeed (that I've tested).
>>>
>>> Because the bug is difficult to trigger, you could be using OpenSCAD for
>>> a long time without encountering the bug. For example, Johan has been
>>> a forum member for some time, but he is just now reporting the bug.
>>>
>>> There are probably a lot of parameterized models out there that
>>> contain the bug, including on Thingiverse, but the author might be
>>> unaware because he didn't test with the magic parameter values that
>>> trigger the bug.
>>>
>>> If we fix this bug, we will likely be fixing bugs in a lot of existing
>>> models,
>>> and we will also be removing a weird pitfall that OpenSCAD users
>>> continue to trip over and report in the forum.
>>>
>>> Doug Moen.
>>>
>>>
>>> On 18 December 2016 at 07:09, Parkinbot <rudolf@parkinbot.com> wrote:
>>>
>>>> Doug,
>>>>
>>>> again a vote for silent behavior and hidden magic - and no means to roll
>>>> back. You propose a solution that will potentially break existing code
>>>> and
>>>> algorithms. The semantical difference can be a "hard to spot" problem as
>>>> soon as nested loops come into play and can affect each (!) nesting
>>>> level.
>>>>
>>>> Look at this double loop, (where only the inner loop is effected, as the
>>>> outer loop is classical):
>>>>
>>>> > first = 6.8;
>>>> > step = .2;
>>>> > last = 8;
>>>> >
>>>> > for (y=[7.4:.05:8.4]) loops(y);
>>>> >
>>>> > module loops(last)
>>>> > {
>>>> > echo(classic = classic_loop(first, step, last));
>>>> > echo(dougs = doug_loop(first, step, last));
>>>> > echo();
>>>> > }
>>>> >
>>>> > function classic_loop(first, step, last) = [for(x = [first: step:
>>>> last])
>>>> > x];
>>>> >
>>>> > function doug_loop(first, step, last) =
>>>> > let(first_ = 0)
>>>> > let(step_ = sign(step))
>>>> > let(last_ = round((last-first)/step))
>>>> > [for(i = [first_: step_: last_]) first+i*step];
>>>>
>>>> this is the output:
>>>>
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>>>> > ECHO:
>>>> > ECHO: classic = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2]
>>>> > ECHO: dougs = [6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 8.2, 8.4]
>>>> > ECHO:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context: http://forum.openscad.org/for-
>>>> statement-doesn-t-do-all-the-steps-sometimes-tp19591p19622.html
>>>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> Discuss@lists.openscad.org
>>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>
RW
Rogier Wolff
Mon, Dec 19, 2016 9:59 AM
On Sun, Dec 18, 2016 at 12:37:41PM -0500, doug moen wrote:
If we fix this bug, we will likely be fixing bugs in a lot of existing
models,
But if you suddenly change behaviour for endvalues = X * start+step,
where X = n + [0.5...1];
you will also create bugs in other existing models.
An automatic epsilon of around step / 2^(mantissa_size - 4) sounds
reasonable to me. Mantissa_size is 24 or 23 for floats, and 48 for
doubles.
This will keep the published behaviour unless you're doing on the
order of 2^20 steps....
Roger.
--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 **
-- BitWizard writes Linux device drivers for any device you may have! --
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.
On Sun, Dec 18, 2016 at 12:37:41PM -0500, doug moen wrote:
> If we fix this bug, we will likely be fixing bugs in a lot of existing
> models,
But if you suddenly change behaviour for endvalues = X * start+step,
where X = n + [0.5...1];
you will also create bugs in other existing models.
An automatic epsilon of around step / 2^(mantissa_size - 4) sounds
reasonable to me. Mantissa_size is 24 or 23 for floats, and 48 for
doubles.
This will keep the published behaviour unless you're doing on the
order of 2^20 steps....
Roger.
--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.
LB
L Boyd
Mon, Dec 19, 2016 5:50 PM
An easier way is to increase your end value by 1/2 the step size.
Larry
View this message in context: http://forum.openscad.org/for-statement-doesn-t-do-all-the-steps-sometimes-tp19591p19631.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
An easier way is to increase your end value by 1/2 the step size.
-----
Larry
--
View this message in context: http://forum.openscad.org/for-statement-doesn-t-do-all-the-steps-sometimes-tp19591p19631.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Wed, Dec 21, 2016 12:23 PM
An easier way is to increase your end value by 1/2 the step size.
Besides breaking codes like Rogier Wolff's ones, Dough's proposal will break
the workaround codes following Boyd's suggestion.
first = 0;
step = 0.2;
last = 1+step/2;
end=first + round((last-first)/step) * step;
echo(end=end);
for(i=[first:step:end]) echo(dough=i);
for(i=[first:step:last]) echo(current=i);
L Boyd wrote
> An easier way is to increase your end value by 1/2 the step size.
Besides breaking codes like Rogier Wolff's ones, Dough's proposal will break
the workaround codes following Boyd's suggestion.
> first = 0;
> step = 0.2;
> last = 1+step/2;
> end=first + round((last-first)/step) * step;
> echo(end=end);
> for(i=[first:step:end]) echo(dough=i);
> for(i=[first:step:last]) echo(current=i);
--
View this message in context: http://forum.openscad.org/for-statement-doesn-t-do-all-the-steps-sometimes-tp19591p19657.html
Sent from the OpenSCAD mailing list archive at Nabble.com.