Negative subscripts in slices: Legal? Documented?

new topic     » topic index » view thread      » older message » newer message

I notice that negative subscripts work in slices (working from the end of the sequence), but I can find no documentation that they do. Is this a feature or a bug?

If a feature, it is surely going to cause some hard to find bugs as bizarre slices like this actually work:

s = {1,2,3,4,5,6} 
? s[$-10..$-8] 

returns {2,3,4}, but I'd kinda like it to crash there.

The above is equivalent to the below, which also works:

s = {1,2,3,4,5,6} 
? s[-4..-2] 

No doubt there are cases when this would be useful, but I think more often it is just going to return a legal slice when in fact you've got a bug in your program and it ought to crash. Any way to make it to act like v3.1?

Is this in the docs somewhere and I missed it?

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu