Entomy / Ada-Improvements

Repository of Ada language improvement ideas
GNU General Public License v3.0
4 stars 0 forks source link

True Pure_Function #29

Open Entomy opened 4 years ago

Entomy commented 4 years ago

Ada does:

pragma Pure_Function();

or

with Pure_Function

This doesn't do anything. No seriously.

It should be:

Actually statically verified

Rationale:

This isn't just a notice to programmers that a subprogram may be "conceptually pure", whatever that actually means. It should be formally verified because there are numerous optimizations and various features that can be implemented in a function-level environment.

One of the most obvious and easy to explain is compile-time expression evaluation. This is only possible in a function-level environment, and formally and statically verifying this directive would allow for this possibility.

Another is proving thread safety. A function-level subprogram is always safe to use in a concurrent environment without locking.