Closed ssbssa closed 2 years ago
It's a questionable feature. I agree that it's very convenient. But it's following a pythonic logic, while duel and gdb expression syntax is built on C logic, e.g. a[-1]
has a well defined semantics in C and gdb and duel, and it can never mean "count from the end", as it has to mean *(a-1)
. The conventional C semantics does not apply to [[ ]]
, so it can use pythonic interpretation. But it'll make the language inconsistent and I suspect it might create problems somewhere later.
But these all aren't very strong arguments against this feature, after all the whole point of duel existence is ease of use. So I'll accept it, provisionally. And if it'll start causing problems (I mean, conceptual problems, not implementation bugs), I'll remove it again.
That's fine with me. I agree with you, if this causes any problems, it should be removed again.
Basically, when in
[[x]]
the x value is negative, add the sequence count to it, so e.g.[[-1]]
would get you the last value in the sequence. Then you wouldn't need the#/
operator where you have to duplicate the full expression, just to get the final value.This would give you the final 3 values:
My implementation looks like this now:
What do you think?
Btw, duel is awesome.