diff options
author | chriseth <chris@ethereum.org> | 2016-09-01 17:02:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 17:02:50 +0800 |
commit | b5d941d3d9f32193c7f9094dee20511585508f6a (patch) | |
tree | 05b5156cbc8fb901102890994842412f18504d06 /docs | |
parent | 4a26adfb7d4e962de094f4c6f02139181fac1699 (diff) | |
parent | 4abba77ddc0b4402597d13d5c29adcf5cac82e11 (diff) | |
download | dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar.gz dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar.bz2 dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar.lz dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar.xz dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.tar.zst dexon-solidity-b5d941d3d9f32193c7f9094dee20511585508f6a.zip |
Merge pull request #935 from chriseth/pragma
Version pragma
Diffstat (limited to 'docs')
-rw-r--r-- | docs/layout-of-source-files.rst | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 6ef06961..fdb7b5e8 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -2,7 +2,36 @@ Layout of a Solidity Source File ******************************** -Source files can contain an arbitrary number of contract definitions and include directives. +Source files can contain an arbitrary number of contract definitions, include directives +and pragma directives. + +.. index:: ! pragma, version + +Version Pragma +============== + +Source files can (and should) be annotated with a so-called version pragma to reject +being compiled with future compiler versions that might introduce incompatible +changes. We try to keep such changes to an absolute minimum and especially +introduce changes in a way that changes in semantics will also require changes +in the syntax, but this is of course not always possible. Because of that, it is always +a good idea to read through the changelog at least for releases that contain +breaking changes, those releases will always have versions of the form +``0.x.0`` or ``x.0.0``. + +The version pragma is used as follows:: + + pragma solidity ^0.4.0; + +Such a source file will not compile with a compiler earlier than version 0.4.0 +and it will also not work on a compiler starting form version 0.5.0 (this +second condition is added by using ``^``). The idea behind this is that +there will be no breaking changes until version ``0.5.0``, so we can always +be sure that our code will compile the way we intended it to. We do not fix +the exact version of the compiler, so that bugfix releases are still possible. + +It is possible to specify much more complex rules for the compiler version, +the expression follows those used by npm. .. index:: source file, ! import |