On Sunday, 25 November 2018 at 05:41:56 UTC, H. S. Teoh wrote:
On Sat, Nov 24, 2018 at 05:48:16PM +0000, Stanislav Blinov via Digitalmars-d-learn wrote:

Yup. UDAs did get in there eventually, and version should too.

I think this would be a trivial DIP, by making it such that a version block inside an enum would lower to the above code. Of course, it could be taken further: the above trick doesn't quite handle this case:

        enum E {
                a,
                version(Windows) {
                        b, c
                }
                version(Posix) {
                        d
                }
        }

That is what Jonathan (and I concur) is talking about.

But this looks like such an antipattern that it probably should be written differently anyway, or just generated via a string mixin.

Why is it an antipattern? Having to version the whole enum just because some stupid C API has two out of a hundred items versioned per platform is an antipattern :)

Granted, it may require some special syntax, i.e.

enum E {
    a,
    b if version(Windows),
    c if version(Windows),
    d if version(Posix),
}

or something to that effect. But there has to be a better way than just versioning the whole enum or resorting to clumsy mixins.
              • Re: ver... H. S. Teoh via Digitalmars-d-learn
              • Re: ver... Adam D. Ruppe via Digitalmars-d-learn
              • Re: ver... H. S. Teoh via Digitalmars-d-learn
              • Re: ver... Neia Neutuladh via Digitalmars-d-learn
              • Re: ver... Jonathan M Davis via Digitalmars-d-learn
              • Re: ver... Stanislav Blinov via Digitalmars-d-learn
              • Re: ver... Jonathan M Davis via Digitalmars-d-learn
              • Re: ver... Stanislav Blinov via Digitalmars-d-learn
              • Re: ver... H. S. Teoh via Digitalmars-d-learn
              • Re: ver... Jonathan M Davis via Digitalmars-d-learn
              • Re: ver... Stanislav Blinov via Digitalmars-d-learn
              • Re: ver... Stanislav Blinov via Digitalmars-d-learn
              • Re: ver... H. S. Teoh via Digitalmars-d-learn
              • Re: ver... Stanislav Blinov via Digitalmars-d-learn
              • Re: ver... H. S. Teoh via Digitalmars-d-learn
              • Re: ver... Adam D. Ruppe via Digitalmars-d-learn
  • Re: version(StdDoc) Jonathan M Davis via Digitalmars-d-learn

Reply via email to