Re:Google Blockly - a visual programming language
by ch on Friday June 01, 2012 @05:30AM
(#4052649)
Still, the blocky code reads "count with i from 0 to (get n)", but the loop generated is accessing A[0-1]..A[n-1]. JavaScript is forgiving here, but A[0..n] is not the same as A[-1..(n-1)] (at least I'm not familiar enough with JavaScript to think otherwise).
[ Parent
| on HN ]
Re:Google Blockly - a visual programming language
by jmaygarden on Friday June 01, 2012 @06:22AM
(#4052739)
If they are mapping index 1 to index 0, then it makes sense that 0 would map to -1 since it is one less than the first index. The bug is in the blockly sieve.
As an aside, Lua also uses 1-based indexing.
I understand why they are offsetting the index, it just makes things somewhat unintuitive. In most programming languages A[-1] is the same as A[len(A)-1] (assuming zero based indexing) ... so in Blocky is A[0] expected to mean the same thing as A[len(A)-1]? Nothing here is a show stopper, just a detail that could use a bit of tightening up.