gbdev/rgbds

[Feature request] Allow indexing macro arguments from the end

Closed this issue · 1 comments

RGBASM's string functions generally support negative indexes for indexing from the end of the string, like how in Python s[-1] is the same as s[len(s)-1]. This would also be convenient for macros. You can't say \<-2>, so currently you have to say DEF idx = _NARG - 1 and then \<idx>. (Remember, macro arguments are 1-indexed, so the last one is _NARGth not _NARG - 1th.) Indexing from the end is useful because macros may have a variable number of arguments, with some fixed-meaning ones at the very beginning and/or very end.

Arguably, having fixed-meaning args at the end is a smell (think cp, and why that necessitated the introduction of cp -t), but fair enough.