1. Integer indexes?
- Posted by DerekParnell (admin) Apr 11, 2021
- 881 views
Is this a bug or a feature?
object X sequence Y Y = "abcdefghijklmnopqrstuvwxyz" X = Y[2.11] ? X
This outputs the value 'b', however I made a typo because I wanted the output to be "bcdefghijk"
2. Re: Integer indexes?
- Posted by _tom (admin) Apr 11, 2021
- 872 views
Y[2.1] gets truncated to Y[2]
standard behavior since early Euphoria
be well
_tom
3. Re: Integer indexes?
- Posted by DerekParnell (admin) Apr 11, 2021
- 855 views
Hi Tom.
I know that this is the behaviour, and that it's been around for ever, but should it be so?
I base this question on these
- The documentation says the sequences take integer indexes.
- Using a literal non-integer index is most likely a typo and not really intended by the coder.
Is anyone's code actually depending on this behaviour?
I'm not talking about variables used as index values that might not be an integer, only literals; that is hard-coded decimal indexes in the code.
4. Re: Integer indexes?
- Posted by petelomax Apr 11, 2021
- 886 views
There might be a few explicit if s[2.99]!=s[2] then crash() in the unit tests, but otherwise I'd agree that should trigger a compilation error.
5. Re: Integer indexes?
- Posted by mitgedanken Apr 11, 2021
- 869 views
There might be a few explicit if s[2.99]!=s[2] then crash() in the unit tests, but otherwise I'd agree that should trigger a compilation error.
+1