Wouldn't this be nice?

Reinier Zwitserloot reinier at zwitserloot.com
Wed Nov 11 10:31:19 PST 2009

How exactly do you imagine the proposed for (char c : string) syntax works?
Hardcoded access to the underlying char array of String itself? That makes
this far more than syntactic sugar; that would have to be a JVM primitive.
That, or the compiler produces a bunch of reflection code which is magically
made exempt from the security manager rules, which, come to think of it,
still smells of being a JVM primitive.

Could be a good idea, but that's rather a lot of impact for a change that is
only useful when needing to iterate character-by-character across very large
strings, or needing to iterate character-by-character across a large number
of large strings. Any other situation and the array copy is an irrelevant
drop in the bucket compared to all the other stuff that will be going on. In
such niche situations, I get the feeling that you probably should roll with
char or even byte arrays from the start, instead of going through

--Reinier Zwitserloot

On Wed, Nov 11, 2009 at 7:00 PM, Bob Lee <crazybob at crazybob.org> wrote:

> On Wed, Nov 11, 2009 at 9:37 AM, Reinier Zwitserloot <
> reinier at zwitserloot.com> wrote:
>> Josh: I'm a bit meh on your suggestion. Is that really so much of an
>> improvement over:
>> for (char c : "someString".toCharArray())?
> Yes. I would never use your suggestion because it results in an extra array
> copy.
> Bob

More information about the coin-dev mailing list