First Impressions
Georg Wrede
georg.wrede at nospam.org
Fri Sep 29 04:55:47 PDT 2006
Lionello Lunesu wrote:
> I also ALWAYS create aliases for char[], wchar[], dchar[]... I DO wish
> they would be included by default in Phobos.
>
> alias char[] string;
> alias wchar[] wstring;
> alias dchar[] dstring;
>
> Perhaps, using string instead of char[], it's more obvious that it's not
> zero-terminated. I've seen D examples online that just cast a char[] to
> char* for use in MessageBox and the like (which worked since it were
> string constants.)
Using char[] as long as you don't know about UTF seems to work pretty
well in D. But the moment you realise that we're having potential
multibyte characters in what essentially is a ubyte[], you get scared to
death, and start to wonder how on earth you haven't yet blown up your
hard disk.
You start having nightmares about slicing char arrays at the wrong
place, extracting single chars that might not be storable in a char, and
all of a sudden you decide to stick with your old language "till things
calm down".
The only medicine to this is simply to shut your eyes and keep coding on
like you never did realise anything.
It's a little like when you first realised Daddy isn't holding your
bike: you instantly fall hurting yourself, instead of realizing that
he's probably let go ages ago, and you still haven't fallen, so simply
keep going.
---
This doesn't mean I'm happy with this either, but I don't have the
energy to conjure up a significantly better solution _and_ fight for it
till it gets accepted. (Some things are just too hard to fix, like
"bit=bool" was, and now "auto/auto".)
More information about the Digitalmars-d
mailing list