In this lesson, you'll:
Pragmas in Solidity are compiler directives, often used to indicate compatible compiler versions or to enable certain compiler features. In the context of Solang, most pragma statements are ignored, as Solang doesn't enforce version matching like Ethereum Solidity.
What are Pragmas?
Example:
pragma solidity >=0.4.0 <0.4.8;
Solang and Pragma Solidity:
pragma solidity
statements are silently ignored.pragma solidity
statement, as it views compiler versions as a part of the build environment rather than the source code.Pragmas in Ethereum Solidity:
Ethereum Solidity uses pragma
to ensure that the compiler version matches what the contract author used.
This approach is meant to prevent any unexpected errors due to language revisions that may make different versions of the compiler incompatible.
The pragma
directive in Ethereum Solidity is a means to enforce compatibility and ensure that the code behaves as expected under a specific compiler version.
Differences in Solang's Approach:
pragma
directives are an integral part of Ethereum Solidity for specifying compiler versions, Solang adopts a different approach, focusing on broader compatibility and viewing compiler versions as an aspect of the development environment rather than the source code.Next, we'll explore various data types supported in Solidity, further enhancing your understanding of the language.