On Saturday, 15 April 2023 at 13:20:09 UTC, kdevel wrote:
Under which circumstances is it a mistake to insert the `return` at the indicated position? If there are none why can't it be done implicitly (automatically)?

It could be done in the easy example you posted, but generalizing it is harder.

When importing a module, the compiler currently doesn't need to analyze function bodies to get the signature of regular (non-auto/template) functions, which would have to change. Programmers can also currently rely on the fact that the signature they see is the signature they get, but not any longer.

The identity function is really simple, but as soon as control flow (if-statements) come into play, the annotations and their inference become a conservative approximation, which might give false positives in `@system` code. There would need to be a second system, one which assumes the best instead of assuming the worst.

This adds complexity, just to add some 'intermediate' safety between `@system` and `@safe` in a few cases. It's better to keep the rules simple and consistent.

  • Re: Returning a ... Jacob Shtokolov via Digitalmars-d-learn
    • Re: Returni... kdevel via Digitalmars-d-learn
      • Re: Ret... Bastiaan Veelo via Digitalmars-d-learn
        • Re:... kdevel via Digitalmars-d-learn
          • ... Dennis via Digitalmars-d-learn
            • ... kdevel via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... kdevel via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... kdevel via Digitalmars-d-learn
              • ... Dennis via Digitalmars-d-learn
              • ... Dennis via Digitalmars-d-learn
              • ... kdevel via Digitalmars-d-learn
              • ... Dennis via Digitalmars-d-learn
              • ... kdevel via Digitalmars-d-learn
              • ... Dennis via Digitalmars-d-learn

Reply via email to