<html><body><div>On Oct 01, 2013, at 08:13 PM, Jonathan M Davis <jmdavisProg@gmx.com> wrote:<br><br class="_stretch"><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch"> The range API won't even work on arrays unless std.array has been imported, <br> and in the case of strings, it depends on std.utf. So, using the range <br> interface underneat the hood for<br> <br> foreach(dchar c; str)<br> <br> would require Phobos. I'd argue for simply fixing how foreach for strings works <br> so that it doesn't use opApply. Worst case, some druntime-specific functions <br> could be written and used to do it, though that would probably require changes <br> in the compiler. But if you want to use a range of some kind, just create one <br> for each character type, and the fact that Phobos treats strings as ranges of <br> dchar should be irrelevant. It does that by having traits like hasLength and <br> isNarrowString treat them that way. There's no reason why you can't have a <br> range of char or wchar if you want to, and if druntime is wrapping strings in <br> ranges for foreach, then it can trivially create a range type which treats <br> strings as ranges of whatever character type you want just so long as front <br> and popFront do the appropriate conversion. Probably another thing to consider <br> in all this is how to deal with foreach_reverse, but that can probably be <br> dealt with as well.<br> <br> I don't particularly like the fact that we're forced to duplicate std.utf stuff <br> in druntime in order to handle foreach, but I don't know of any way around <br> that short of moving std.utf (or some portion of it) into druntime. It's <br> pretty much the same problem that we have with the fact that std.traits isn't <br> available in druntime, except that the implementation for decode and stride <br> are a bit more complicated than most traits.</div></div></blockquote><span></span><br>Can't we move some of the functionality to druntime? It doesn't need to be duplicated. Move what we can to druntime and publicly import that in Phobos.<br><br>--<br>/Jacob Carlborg<br></div></div></body></html>