Open apblack opened 7 years ago
While the meaning of "a".."z" seems obvious, the meaning of "wombat".."kangaroo" is less so. We could define .. just for single-character strings. Is this a bad idea?
there are other things like "code" that look at only the first character of the string.
Perl has semantics for string ranges (well string++) that are... interesting:
if the string matches /^[a-zA-Z][0-9]\z/ ), then in it increments it otherwise just returns the first element of the range.
J
Seems fine to have it restricted to single character strings.
Kim
On Jun 7, 2017, at 5:17 PM, Andrew Black notifications@github.com wrote:
The range notation a..b works only for numbers, not (right now) for Strings. Students seem to expect it to.
While the meaning of "a".."z" seems obvious, the meaning of "wombat".."kangaroo" is less so. We could define .. just for single-character strings. Is this a bad idea?
The .. operator on Numbers is defined only for integers — it's not total on all numbers. So it would not be inconsistent to make .. partial on Strings.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gracelang/language/issues/128, or mute the thread https://github.com/notifications/unsubscribe-auth/ABuh-mbggmBvKH2AgIMbxi_T7B1--_aaks5sBz2CgaJpZM4Nzbtn.
I think that we should implement ..
for single-character strings. I don't think that James is really suggesting that we follow the example of Perl, so I won't worry about that issue.
The range notation a..b works only for numbers, not (right now) for Strings. Students seem to expect it to.
While the meaning of "a".."z" seems obvious, the meaning of "wombat".."kangaroo" is less so. We could define .. just for single-character strings. Is this a bad idea?
The .. operator on Numbers is defined only for integers — it's not total on all numbers. So it would not be inconsistent to make .. partial on Strings.