On Dec 16, 2007 10:10 PM, Per Bothner <[EMAIL PROTECTED]> wrote: > I agree 100%. Unfortunately, many languages don't have a way to > iterative except by index. It would be better to have an > abstract position P, plus various X operations to yield the > pair (next X starting at P, position following that X), > perhaps integrated with some kind of parsing / pattern-matching > engine.
Indeed. > Given that programmers will use "character index" as offered > by the language, a language implementor needs to implement that, > preferably with O(1) time, or not be properly compliant. Alas. I think the idea of a "no smoking, surrogate code units in use" flag testable in O(1) time on an immutable Java-type string is an excellent idea, and I hope it is taken up by the JVM some day. > > I hope that as time goes on, just as languages have accepted > > Unicode as a base representation, they will come to accept > > iterators as a base access method, with strings seen as > > neither atoms nor sequences, but a tertium quid that can > > be iteratively dissected into parts (which are also strings) in > > any of a large variety of ways. > > Right, especially since these day a "string" may have further > structure, such as nested "elements". An iterator or "position" > framework also can also handle structured data better. I should also add, primarily for the benefit of those who may be listening, that adopting this model implies the demise of "character" as a data type, and the notion that a string is a sequence of characters. Numbers are represented visually as a sequence of digits, but we do not find it necessary to introduce a "digit" type to our programming languages and conceptualize arithmetic in terms of the combination of digit sequences with each other to produce more digit sequences. -- GMail doesn't have rotating .sigs, but you can see mine at http://www.ccil.org/~cowan/signatures --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---
