Why does solidity (*sol) file starts with pragma? What does pragma stands for and its origins?
2 Answers
The version pragma is included because future versions of solidity will likely not be compatible with the current 0.4.* version. Specfically, 0.5.0 will likely have breaking changes.
Pragma was borrowed from other languages, such as C and C++, that use it as a preprocessor directive.
-
Compiler directive I believe, but yes. An instruction to the program processing the file, and not an instruction to be compiled. Apr 4, 2018 at 12:52
It gives the solidity compiler a hint on how to process the code. E.g. if it should allow new features. For more general information on the usage of pragma in programming you might want to read this: https://en.wikipedia.org/wiki/Directive_(programming)