D Language Gotchas
Meta
jared771 at gmail.com
Tue Nov 5 03:16:53 PST 2013
On Tuesday, 5 November 2013 at 02:59:55 UTC, Sumit Adhikari wrote:
>
>
> Dear All,
>
> I searched internet also I searched this forum for D Language
> gotchas. In this forum, I found a thread which is from 2005 and
> I do not know latest updates on that.
>
> My question is that - "Are there known programming gotchas of D
> language ?"
>
> If will be grateful if I get some pointers.
>
> Regards, Sumit
One gotcha relates to enums. Writing `enum a = [0, 1, 2]` is a
really bad idea, because everywhere you use a, it constructs a
new array at runtime. The [0, 1, 2] is "pasted in", and you'll
have a bunch of allocations you didn't expect. This doesn't just
happen with arrays, but that's the most common case. What *is*
okay is using string enums, as strings are a bit special due to
being immutable.
More information about the Digitalmars-d
mailing list