Hitchikers Guide to Porting Phobos / D Runtime to other architectures

Johannes Pfau nospam at example.com
Wed Jan 8 08:22:37 PST 2014


Am Wed, 08 Jan 2014 15:59:25 +0000
schrieb "Adam D. Ruppe" <destructionator at gmail.com>:

> On Wednesday, 8 January 2014 at 15:21:21 UTC, Johannes Pfau wrote:
> > But IIRC druntime does some UTF normalization or something on 
> > strings or was that only for foreach over strings?
> 
> No, all it does is if you ask for foreach(dchar c; string){}, it 
> will decode the multi-byte sequences. This does not require 
> druntime, the compiler just outputs the code for it.

Are all the aApplay methods deprecated then? See
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aApply.d

which also imports rt.util.utf.

> 
> Decoding the multi byte sequences isn't much code, it is just 
> some loads, shifts, and bit masks. Fairly lightweight.

But it is _some_ code. It's always a matter of perspective, but on a
8bit AVR with 4-16KB for code you probably don't want to implement
these functions in the runtime. Instead you just want the compiler to
complain if someone does foreach(dchar, "string"). If this is really
needed on small systems it's always possible to implement a range to do
this:

foreach(dchar x; decode("string"))


Don't get me wrong, I think this is just fine in normal D, but in
embedded D it would be nice if the runtime could disable that feature.


More information about the Digitalmars-d mailing list