-
• #2
Wow, thanks. No idea how that happened - and it's been a problem since at least 2v00.
I'll get on to a fix for this now
-
• #3
Ok, now fixed (in cutting edge or 2v07)
-
• #4
Thanks - As quickly as usual!
-
• #5
Neat... I use(d) pre-decrement quite a lot (when walking an array (backwards when direction did not matter)... luckily I used just the
while () ...;
and not thedo ... while()
construct and never noticed an issue... ...and there is no issue with it... (the 'real' pre-pre-decrement...) - haha (I usually try NOT to enter a loop unconditionally... it is increased risk for an infinite loop (and it has messed with me). Of course, even with an upfront conditioned loop, an infiniteloop is possible, but much less because 'the break/exit thinking' is done upfront rather than an after thought. If I wanted to run the loop at least once, that would go also into the setup of the upfront condition... and thought. I'm though very aware of the fact that thedo ... while()
construct can be very useful (and is actually very Espruino-economic): it conveys already by its very architecture that the loop body is executed at least once where as with the upfront condition that fact is masked and only understood by wading the start values and the condition. @MaBe, saw your post the day before. Even though it is fixed now, i wanted to know if I was affected by it.// predecrement.js function predecTest() { var i=5; // for example: ...=array.legth() while(--i >= 0) console.log(i); // walk array console.log("----(1)"); var j=4; // for example: ...=array.legth()-1 while (j >=0) { console.log(j); j--; } console.log("----(2)"); var k=5; // for example: ...=array.legth() while (k > 0) { k--; // walk array console.log(k); } console.log("----(2)"); var l=4; // for example: ...=array.legth()-1 do { console.log(l); } while(--l >= 0); // walk array console.log("----(4)"); } function onInit() { predecTest(); } setTimeout(onInit,999);
Output:
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams > 4 3 2 1 0 ----(1) 4 3 2 1 0 ----(2) 4 3 2 1 0 ----(2) 4 2 1 0 ----(4) >
-
• #6
it's been a problem since at least 2v00.
Says something about how often people use do...while() loops doesn't it?
Why do this two do while loops produce different output?
Code was running on a PICO_R1_3 with 2v06.49.