It seems a little weird that the second parameter switches meaning from "end" to "length" if the first parameter is negative, but I suppose it's more useful than the alternative...
Well we can only speculate. He said he wants to reserve '?' for ssyntax, and I pointed out '?' in ssyntax and lone '?' can coexist. If he also reserve lone '?', that's his decision.
Your "items from position 1 to the end minus the last 2 items" can actually be achieved in a nicer manner in Arc:
(cut s 1 -2)
(Note that that's using the Anarki negative-end semantics, which PG has said are better; in arc1.tar, that would be (cut s 1 -3). See http://arclanguage.org/item?id=2225)
I think PG has said before that he'd like to allow prefix, infix, and postfix operators to be programmable by the user. So I'd guess that, yes, there are such plans.
Agreed. Ruby does it the other way ("abcde"[1..-1] is "bcd"), but that's only because there's no other way to specify "until the end." But that's the default in Arc; the following are equivalent right now:
Both nil and (len str) work. I see both sides of the argument as counting from -1 eliminates the 0 corner case.
I like indices that are intuitive with literal numbers. Counting from 0 at one end and from 1 at the other is jarring. When -1 points to the end of string rather than before the last char (cut str 0 (- (len str))) returns the first char instead of the empty string.
With -1 -> before last char:
(def chop ((o str "abcdef"))
(pr "Chop how many chars off the end of \"" str "\"? ")
(= n (coerce (cut (readline) 1) 'int)) ; bug in readline prepends #\newline
(prn "Chopped: \"" (if (is n 0) str (cut str 0 (- n))) "\"")) ; handle corner case
With -1 -> end of string:
(def chop ((o str "abcdef"))
(pr "Chop how many chars off the end of \"" str "\"? ")
(= n (coerce (cut (readline) 1) 'int)) ; bug in readline prepends #\newline
(prn "Chopped: \"" (cut str 0 (- -1 n)) "\"")) ; no corner case, but there's this -1 there
I probably made a stronger argument for -1 pointing to the end of string as it leads to shorter code.
I've added this as branch "official" of the arc wiki. I've also tried to merge it into the master branch. I resolved everything I knew how, but there might be some regressions and references to renamed/no-longer-existent functions hanging around.
it would be nice if we made specs to test the language, a la Rubinius, while the language is still small. Then, we could say with greater confidence of the merge.