Implicit enum conversions are a stupid PITA

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 24 11:22:55 PDT 2010


On 03/24/2010 12:57 PM, Nick Sabalausky wrote:
> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org>  wrote in message
> news:hod5o3$1nhg$1 at digitalmars.com...
>> On 03/24/2010 08:28 AM, bearophile wrote:
>>> As
>>> they say: "Those who cannot learn from C# are doomed to re-invent it,
>>> often badly."
>>
>> Who are "they"?
>>
>
> He was modifying the common expression "Those who don't learn from the past
> are doomed to repeat it."

But paraphrasing ain't "as they say" because they don't say that. 
Besides, I thought he's paraphrasing "Any sufficiently complicated C or 
Fortran program contains a buggy implementation of Common Lisp." But I 
guess that's just me being cranky - I'm sick.

>>> (In D you can solve this problem creating a flags struct, using a
>>> strategy similar to the one used by std.bitmanip.bitfields, but it
>>> feels hackish).
>>
>> Why does a mechanism that allows creating bitfields, custom enums, flags,
>> custom-base literals, and more, feel hackish,
>
> Because it involves passing everything as parameters to a
> string-mixin-generating function/template. Powerful as such as thing is, and
> as much as I like having that ability available, it is a rather blunt
> instrument and does tend to feel very hackish.

Feeling is subjective. To me it doesn't.

> Also, looking at the docs for bitmanip, it looks like "bitfields" creates a
> "BitArray". But the interface for bitarray doesn't really seem to match the
> conceptual-level operations performed on bitfields any more than just using
> an ordinary uint would, and it doesn't seem to solve most of the problems
> with doing so, either.

Nonsense. bitfields does not create a BitArray and does exactly what 
you'd expect some bit fields to do. To saliently criticize an artifact, 
it does help to understand it.

>> whereas dumping a wheelbarrow of narrow-usefulness features with every
>> release
>
> Custom bitfields are extremely useful for low-level code. Being a
> self-proclaimed "systems" language, there's no reason D should consider such
> a thing to be of "narrow-usefulness".

First, custom bitfields are taken care of appropriately by bitfield. You 
may want to try it before replying. Second, this thread is about enums 
that are bitwise flags, so I take it you replied to disagree with every 
paragraph I wrote.

>> while still failing to address major problems (concurrency, immutability)
>> feels not?
>>
>
> I don't think anyone's suggesting that things like concurrency and
> immutability should fail to be addressed.

Then stop extolling the virtues of an obscure feature.


Andrei



More information about the Digitalmars-d mailing list