Let's define a function decorator called functional that, while compiling, checks if the function body adheres to functional programming rules.
functional int add(int a, int b) { return a + b; }Rules may be:
How are you going to implement functional, and what language are you assuming, CeePlusPlus?
If you are speaking abstractly and not assuming a target language, and not worrying about whether functional is implementable, then what does this gain over just assuming that you're programming in a pure functional language to start with?
It may be implemented in existing languages like CeeLanguage, CeePlusPlusLanguage?, JavaLanguage, CeeSharp etc. It must be implemented in compilation phase. I think it can leverage testability and optimizations.
In other words, you're proposing that it be a new language, or rather, a new dialect of some AlgolFamily language. That's why I asked; it would be close to impossible to achieve all of those objectives purely within any of those languages, as opposed to modifying a compiler.
BTW purely functional AlgolFamily languages have been created in the past.
It's still confusing as to whether you are actually proposing something, or just thinking out loud, since you don't seem to care very much which particular language is used, nor do you sound like you're planning to implement such a thing, nor do you sound like you're asking anyone else to.
Yes, I'm just thinking out loud.
GnuCompilerCollection allows you to do this sort of thing (in GnuCpp) as a nonstandard extension. [all of the above? How?]