Open shazz opened 4 years ago
BTW, the python range
is IMO a bit funky:
>>> list(range(10, 0, -1))
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
This is not the same as just looping the list in reverse:
>>> list(reversed(range(0, 10)))
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
Looks like a great source of off-by-one errors.
Alternative would be to add a built-in reversed()
function like in Python. This would be the same as your plugin, except built-in.
Do we want to pollute the symbol namespace with many functions like this? Or maybe something like:
!for i in range(10).reverse() {
}
This type of array prototype calling convention is not currently supportd in c64jasm.
PS:
module.exports = {
reverse: ({}, val) => {
return val.reverse();
}
}
Whoops! JavaScript reverse() is in-place. You should not mutate the plugin input arguments. (I should document this!)
As a workaround, a js plugin works well but as you implemented the python style for loop style using range(), could be nice to also support backwards loop like
Here is my javascript plugin:
ex: