ID:2498498
 
Not a bug
BYOND Version:512
Operating System:Windows 10 Preview
Web Browser:Chrome 76.0.3809.100
Applies to:Dream Maker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
Unable to call list element from end
Numbered Steps to Reproduce Problem:
Steps: 3
1. Write in code:
var/list/L = list("1", "2", "-1")
world<< L[-1]

2. Compile
3. Get runtime with "List out of bound.", and it will return null replacing it value.
Code Snippet (if applicable) to Reproduce Problem:
var/list/L = list("1", "2", "-1")
world<< L[-1]


Expected Results:
return to world of list's element "-1".
Actual Results:
Runtime: "List out of bound."
Does the problem occur:
Every time

When does the problem NOT occur?: N/A

Workarounds:
LISTNAME[length(LISTNAME)]

Lummox JR resolved issue (Not a bug)
-1 and "-1" are different things.
In response to Lummox JR
Lummox JR wrote:
Lummox JR resolved issue (Not a bug)

It isn't bug, it imperfection
In response to Lummox JR
Lummox JR wrote:
-1 and "-1" are different things.

"-1" it end element of
var/list/L = list("1", "2", "-1")
You're trying to access
L[-1]


Which is a numerical index, -1 is not a valid list index. You'd want
L["-1"]


Which is a different thing.
In response to Nadrew
Nadrew wrote:
You're trying to access
> L[-1]
>


Which is a numerical index, -1 is not a valid list index. You'd want
> L["-1"]
>


Which is a different thing.
I told this is shortcoming.
I watching to, for example, python and it work with [-1]
>>> i = ["1", "2", "-1"]
>>> i[-1]
'-1'


I gave this code:
var/list/L = list("1", "2", "-1")
world<< L[-1]

as an example where "-1" setted as indicator for showing what should returns by [-1]
Negative list index access isn't a thing in all languages--or even most of them. It sounds like you really want to do a feature request, because this isn't a bug.
In response to Nadrew
For text-vartype we have 'copytext' and it can work like:
copytext(text, -1, -4)
In response to Lummox JR
Lummox JR wrote:
Negative list index access isn't a thing in all languages--or even most of them. It sounds like you really want to do a feature request, because this isn't a bug.

Sorry if i mistake with forum section, can you link me to correct section?
In the meantime,

world << L[L.len]
In response to Nadrew
Nadrew wrote:
In the meantime,

> world << L[L.len]
>

Watch to Workarounds there the same:
LISTNAME[length(LISTNAME)]

It's a crutch, like "WORK AS I WANT, CODE, PLEASE"
Just because one language has it, doesn't mean they all will. This is actually a fairly uncommon language feature.

It's not a bad request, but the attitude of "another language has it, this one MUST have it or they HAVE to add it" is not ideal.
In response to Nadrew
Nadrew wrote:
Just because one language has it, doesn't mean they all will. This is actually a fairly uncommon language feature.

It's not a bad request, but the attitude of "another language has it, this one MUST have it or they HAVE to add it" is not ideal.

I don't say that "If python have this, so DM MUST have it."
I used python as example where this feature used.
I say "It wouldn't be bad, if it were in DM", but mb you hasn't understood me, cuz of my semi-bad english, but i mean it.