What's left for 1.0?
Daniel Keep
daniel.keep.lists at gmail.com
Mon Nov 20 04:26:13 PST 2006
Olli Aalto wrote:
> Marcin Kuszczak wrote:
>> But if Walter is not happy enough with this implementation now maybe
>> there
>> should be at least added alias in object.d:
>> alias char[] string;
>>
>
> I'm not an expert on these things, but while reading Daniel Keep's
> excellent article on text in D, I got an idea about the alias
> declaration. Why not have something like this in either object.d or
> std.string?
>
> version(UTF8)
> {
> alias char[] string;
> }
> version(UTF16)
> {
> alias wchar[] string;
> }
> version(UTF32)
> {
> alias dchar[] string;
> }
>
> It would default to UTF8, if not defined on command line. This way
> everyone could use the version their application requires.
>
> Am I way out of line here? As I said I'm not an expert and don't know if
> that just creates more problems.
>
> O.
Imagine you compile the standard library with -version=UTF8. Let's take
the following function:
> int find(string s, dchar c) { ... }
This would be compiled as:
> int find(char[] s, dchar c) { ... }
You then write some code to use that:
> ...
> string attr = "key:value";
> ...
> auto pos = find(attr, ':');
> ...
For whatever reason, your program will run optimally using UTF-32.
> dmd -version=UTF32 app.d
But that means that in the standard library, "string" is really
"char[]", and in your program it's "dchar[]". You try to link against
the standard library, and the linker barfs (quite correctly) since the
function you're using doesn't exist.
It's a nice idea, but with the current object formats, and the way
conditional compilation works, I don't think it's actually possible.
-- Daniel
P.S. See sig.
--
Unlike Knuth, I have neither proven or tried the above; it may not even
make sense.
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list