diff options
author | Araq <rumpf_a@web.de> | 2012-03-13 02:01:56 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-03-13 02:01:56 +0100 |
commit | c25ffbf2622a197c15a4a3bd790b1bc788db2c7f (patch) | |
tree | d1a23e97a11a92bc83286fd77ba4e4a953d753fa /doc | |
parent | 1d8ff40f5679d3ddfa10a89b0333a0132ee1e1b2 (diff) | |
download | Nim-c25ffbf2622a197c15a4a3bd790b1bc788db2c7f.tar.gz |
first steps for cleaner static/const distinction
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/advopt.txt | 1 | ||||
-rwxr-xr-x | doc/grammar.txt | 6 | ||||
-rwxr-xr-x | doc/keywords.txt | 2 | ||||
-rwxr-xr-x | doc/manual.txt | 24 |
4 files changed, 30 insertions, 3 deletions
diff --git a/doc/advopt.txt b/doc/advopt.txt index b43e5e511..876e04904 100755 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -51,6 +51,7 @@ Advanced options: --tlsEmulation:on|off turn thread local storage emulation on|off --taintMode:on|off turn taint mode on|off --symbolFiles:on|off turn symbol files on|off (experimental) + --implicitStatic:on|off turn implicit compile time evaluation on|off --skipCfg do not read the general configuration file --skipUserCfg do not read the user's configuration file --skipParentCfg do not read the parent dirs' configuration files diff --git a/doc/grammar.txt b/doc/grammar.txt index 325a29ad5..4fb18024d 100755 --- a/doc/grammar.txt +++ b/doc/grammar.txt @@ -26,6 +26,7 @@ indexExpr ::= expr castExpr ::= 'cast' '[' optInd typeDesc optPar ']' '(' optInd expr optPar ')' addrExpr ::= 'addr' '(' optInd expr optPar ')' +staticExpr ::= 'static' '(' optInd expr optPar ')' symbol ::= '`' (KEYWORD | IDENT | operator | '(' ')' | '[' ']' | '{' '}' | '=' | literal)+ '`' | IDENT @@ -37,7 +38,7 @@ primarySuffix ::= '.' optInd symbol [generalizedLit] | '{' optInd [indexExpr (comma indexExpr)* [comma]] optPar '}' primary ::= primaryPrefix* (symbol [generalizedLit] | - constructor | castExpr | addrExpr) + constructor | castExpr | addrExpr | staticExpr) primarySuffix* generalizedLit ::= GENERALIZED_STR_LIT | GENERALIZED_TRIPLESTR_LIT @@ -97,7 +98,7 @@ simpleStmt ::= returnStmt | includeStmt | exprStmt complexStmt ::= ifStmt | whileStmt | caseStmt | tryStmt | forStmt - | blockStmt | asmStmt + | blockStmt | staticStmt | asmStmt | procDecl | iteratorDecl | macroDecl | templateDecl | methodDecl | constSection | letSection | varSection | typeSection | whenStmt | bindStmt @@ -131,6 +132,7 @@ tryStmt ::= 'try' ':' stmt ['finally' ':' stmt] asmStmt ::= 'asm' [pragma] (STR_LIT | RSTR_LIT | TRIPLESTR_LIT) blockStmt ::= 'block' [symbol] ':' stmt +staticStmt ::= 'static' ':' stmt filename ::= symbol | STR_LIT | RSTR_LIT | TRIPLESTR_LIT importStmt ::= 'import' filename (comma filename)* includeStmt ::= 'include' filename (comma filename)* diff --git a/doc/keywords.txt b/doc/keywords.txt index c4e073417..9638dc12a 100755 --- a/doc/keywords.txt +++ b/doc/keywords.txt @@ -12,7 +12,7 @@ nil not notin object of or out proc ptr raise ref return -shl shr +shl shr static template try tuple type var when while with without diff --git a/doc/manual.txt b/doc/manual.txt index 9627e18c7..9b5362324 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -1640,6 +1640,30 @@ Constants cannot be of type ``ptr``, ``ref``, ``var`` or ``object``, nor can they contain such a type. +Static statement/expression +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Syntax:: + staticExpr ::= 'static' '(' optInd expr optPar ')' + staticStmt ::= 'static' ':' stmt + +A `static`:idx: statement/expression can be used to enforce compile +time evaluation explicitely. Enforced compile time evaluation can even evaluate +code that has side effects: + +.. code-block:: + + static: + echo "echo at compile time" + +It's a static error if the compiler cannot perform the evaluation at compile time. + +The current implementation poses some restrictions for compile time +evaluation: Code which contains ``cast`` or makes use of the foreign function +interface cannot be evaluated at compile time. Later versions of Nimrod will +support the FFI at compile time. + + If statement ~~~~~~~~~~~~ |