Revisiting TO and THRU

If you asked someone to count "from 1 to 10", how many people would stop at 9?

I'd say most wouldn't. So if you wrote:

for x [1 to 10] [print [x]]

What should that do? I think if you showed it to people they would expect 10 to be included.

But PARSE has historically discerned this via TO (not including the limit) and THRU (including the limit).

Is that right? Should TO be inclusive, and some other word along the lines of "UPTO" be used?

I almost feel like the words are slippery enough that we could bend them so that THRU was the non-inclusive version. :-/

In PARSE, if TO included the limit, you could go up-to-but-not-include by using AHEAD with it: to ahead "A"

We could say that UNTIL would keep advancing until it hit the rule and then stopped short of it: until "A".

Would that convey the right thing in the FOR case?

>> for x [1 until 10] [print [x]]
1
2
3
4
5
6
7
8
9

If you count upto 10 you don't stop at 9 either

1 Like

True. Any feelings about "count until 10" not including 10?

Before seems more explicit

Well that doesn't read clearly standalone:

for [1 before 10] [...]  ; huh?

If you combine it with TO, it does:

for [1 to before 10] [...]

This could be used in PARSE if we rename AHEAD as BEFORE, which seems pretty coherent:

>> parse "aaabbb" [to "b", tally "b"]
== 2

>> parse "aaabbb" [to before "b", tally "b"]
== 3

UNTIL as a shortcut for TO BEFORE seems reasonable as well.

Although arguably... all numbers 9 and less are before 10. So a loop talking about a "BEFORE" condition when it's at 1 could reasonably not run at all.

How about yet ?

For [1 yet 10] [•••]

Or, borrowing from another language

For [1 nyet 10] [•••]