Why the hell doesn't foreach decode strings
bearophile
bearophileHUGS at lycos.com
Fri Oct 21 16:38:14 PDT 2011
Andrei Alexandrescu:
> Latching on the notion that a problem is unsolvable is highly nocive because it sets
> up the mind for failing to not only look for solutions, but also to see
> and understand them when they're in the open.
Right. Experimental psychology has confirmed this some decades ago :-)
> I said this a number of times, and I repeat:
Maybe I have missed your precedent explanations of this idea. Or to me this time it seems more clear and focused.
> if we had the luxury of doing it over again,
Unfortunately D3 language can't break too much backward compatibility :-|
> I'd disable random access and .length for char[],
> wchar[], and their qualified versions. For those types I would add a
> property .rep that yields respectively ubyte[], ushort[], and the
> appropriately-qualified variants.
Good. But the need to know the length of a variable-sized string is common. So I presume in such cases you have to use:
somestring.walkLength()
This is not too much bad, but it looks a bit long, and it requires an import. So maybe a shorter named property function in the object module is needed:
somestring.wlength
What about slices? I do need to take slices of variable-length strings too.
Bye,
bearophile
More information about the Digitalmars-d
mailing list