Open jayvdb opened 3 years ago
@jayvdb Existing testcases didn't catch this one.. Ruby uses a greater than, whereas python is a greater-than/equal-to for positive steps
But this seems a little tricky to do "in-place" as the range step may be ascending or descending.
I'm not sure how much this deviates from the original philosophy of trying to do as much as possible in-line, but I think an additional range-function: PyLib.range()
on the ruby side that closely maps to python's behavior is the best way to proceed in terms of correctness - at the expense of having to include the module using either the -r/-b options for py2rb.
I am open to either approach. py2many
transpilers usually have a supporting library to deal with Python, and I am already adding a -r .../py2rb/builtins/module.rb
in my wrapper. However most also implement Python range
by doing +1 or -1 on the args in-place. See https://github.com/adsharma/py2many/search?q=visit_range
should emit 2->8, stepped by two
The transpiler emits
which emits 2->10, stepped by two