D Language Gotchas
Sumit Adhikari
sumit.adhikari at gmail.com
Tue Nov 5 05:07:25 PST 2013
One big gotcha of this forum is that when I reply I will have to
reply only one person and hence I cannot thank everybody using
one mail!
Indeed I am happy that I have some pointers and I thank everybody
for participation. My need was to create a qualitative analysis
document for the case of one out of three languages - D, C++ and
something-else.
I will investigate more and come back to you people if I am stuck.
Regards, Sumit
On Tuesday, 5 November 2013 at 12:27:55 UTC, Jacob Carlborg wrote:
> On 2013-11-05 12:16, Meta wrote:
>
>> 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.
>
> Isn't the problem rather that [0, 1, 2] allocates in the first
> place, regardless if an enum is used or not.
More information about the Digitalmars-d
mailing list