On Fri, 30 May 2014 13:34:38 -0400, Philippe Sigaud via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli
<digitalmars-d-learn@puremagic.com> wrote:
On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote:

         enum double p0 = 0.0045;

As others have already said, p0 is a manifest constant. Interestingly, it
can be thought of like a C macro, being pasted inside source code.

Avoid enums for arrays and associative arrays as they are hidden performance sinks. The constant gets regenerated at runtime every time it is used in an
expression.

I guess that, in an ideal world, immutable variables could be use at
compile-time (template arguments, etc). We could then ditch
'enums-as-manifest-constants'.The best of both worlds.

You can as long as the value is known at compile time:

http://dpaste.dzfl.pl/5a710bd80ab0

-Steve
  • enums Russel Winder via Digitalmars-d-learn
    • Re: enums bearophile via Digitalmars-d-learn
      • Re: enums Philippe Sigaud via Digitalmars-d-learn
        • Re: enums H. S. Teoh via Digitalmars-d-learn
          • Re: enums Philippe Sigaud via Digitalmars-d-learn
    • Re: enums monarch_dodra via Digitalmars-d-learn
    • Re: enums Ali Çehreli via Digitalmars-d-learn
      • Re: enums Philippe Sigaud via Digitalmars-d-learn
      • Re: enums Steven Schveighoffer via Digitalmars-d-learn
        • Re: enums Philippe Sigaud via Digitalmars-d-learn
    • Re: enums via Digitalmars-d-learn

Reply via email to