Why explicit cast?
Andreas Kochenburger
akk at nospam.org
Mon Feb 12 11:40:15 PST 2007
Jarrett Billingsley wrote:
> "Andreas Kochenburger" <akk at nospam.org> wrote in message
> news:eqo451$8p9$1 at digitalmars.com...
>
>> The C-syntax is as clear as tap water, so why had this complication been
>> added?
>
> After having used D for more than two years, I'll have to disagree with this
> comment ;) Besides, as Joel said, your code really shouldn't have a lot of
> casts in it, unless you're programming "in C" in D.
First thanks to all those who have answered.
Indeed I am programming "in C" in D i.e. I am converting a small
compiler from C to D, to test if D would make life easier for me.
The program uses a lot of pointers of different types to address bits
and bytes and ints and floats etc. in a memory region directly. Probably
this kind of system programming is not an ideal application for D.
I got also a bit frustrated about the (at least for me, messy) "very"
flexible string handling in D: static arrays, dynamic arrays, strings,
C-like strings (to be converted with toStringz), then I have to import
std.c.string and std.string and then I have to add .ptr to a pointer to
a static array string, when I use the C-function strtok from
std.c.string it claims char* pointers and does not want char[] because
it is a static array and its name is not the pointer to its first
element etc etc ..... grrrrrgh
More information about the Digitalmars-d-announce
mailing list