On 12/6/17 12:04 PM, A Guy With a Question wrote:

I really do think, regardless of if this is considered a template expansion, that dmd should be catching these obvious errors. When one writes interfaces and abstract classes they are generally not ready to implement the end class yet. And getting a ton of errors at once when that occurs is really hard to deal with. I really don't understand why the compiler would have issues with this.

So, it is important to note that a template must successfully *parse*, but it cannot be semantically analyzed until it is instantiated.

It is no different from C++ templates.

So why wouldn't the compiler fail? Because it has no idea yet what you mean by Nullable. It doesn't even know if Nullable will be available or not. You could even import Nullable, but Nullable!T may be an error.

This is definitely different from Generics (which I think you are familiar with), where there is some semblance of structure implied in the wildcard types. With templates, the type can be anything.

It might be possible to do some deduction of whether something will EVER compile, but it's probably not worth the extra work.

Did you waste your time? No. It seems like all your errors are simple import problems, just fix the bugs, and you should be good!

For the future, the correct way to write templates like this is to instantiate them in tests. Use unittesting, and you shouldn't have problems like this.

-Steve
  • Does dmd not always compile ... A Guy With a Question via Digitalmars-d-learn
    • Re: Does dmd not always... Atila Neves via Digitalmars-d-learn
      • Re: Does dmd not al... A Guy With a Question via Digitalmars-d-learn
        • Re: Does dmd no... A Guy With a Question via Digitalmars-d-learn
          • Re: Does dm... A Guy With a Question via Digitalmars-d-learn
            • Re: Do... A Guy With a Question via Digitalmars-d-learn
              • Re... A Guy With a Question via Digitalmars-d-learn
                • ... Nick Treleaven via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... A Guy With a Question via Digitalmars-d-learn
                • ... A Guy With a Question via Digitalmars-d-learn
                • ... Atila Neves via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... user1234 via Digitalmars-d-learn
            • Re: Do... Gary Willoughby via Digitalmars-d-learn
    • Re: Does dmd not always... Adam D. Ruppe via Digitalmars-d-learn

Reply via email to