diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-01-26 12:58:44 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-01-26 12:58:44 +0100 |
commit | cfe5447e95be278f896a672a51b838d7243ca813 (patch) | |
tree | 1cedb9e40f84d35ee1e0c6912275b9a17edd5b87 /doc/manual | |
parent | 1fbeedaba25af170bfb3ad00de1ccad1f8da1546 (diff) | |
parent | cd574d197646f6d77bc6045d9bdc16982fc14548 (diff) | |
download | Nim-cfe5447e95be278f896a672a51b838d7243ca813.tar.gz |
Merge pull request #3777 from sheerun/echo
Promote "echo" syntax without parenthesis
Diffstat (limited to 'doc/manual')
-rw-r--r-- | doc/manual/exceptions.txt | 10 | ||||
-rw-r--r-- | doc/manual/modules.txt | 2 | ||||
-rw-r--r-- | doc/manual/procs.txt | 10 | ||||
-rw-r--r-- | doc/manual/stmts.txt | 32 | ||||
-rw-r--r-- | doc/manual/types.txt | 2 |
5 files changed, 28 insertions, 28 deletions
diff --git a/doc/manual/exceptions.txt b/doc/manual/exceptions.txt index 0010d5d09..d35130600 100644 --- a/doc/manual/exceptions.txt +++ b/doc/manual/exceptions.txt @@ -15,15 +15,15 @@ Example: try: var a = readLine(f) var b = readLine(f) - echo("sum: " & $(parseInt(a) + parseInt(b))) + echo "sum: " & $(parseInt(a + parseInt(b))) except OverflowError: - echo("overflow!") + echo "overflow!" except ValueError: - echo("could not convert string to integer") + echo "could not convert string to integer" except IOError: - echo("IO error!") + echo "IO error!" except: - echo("Unknown exception!") + echo "Unknown exception!" finally: close(f) diff --git a/doc/manual/modules.txt b/doc/manual/modules.txt index ac47d89dd..9cb6a11af 100644 --- a/doc/manual/modules.txt +++ b/doc/manual/modules.txt @@ -144,7 +144,7 @@ modules don't need to import a module's dependencies: # B.MyObject has been imported implicitly here: var x: MyObject - echo($x) + echo $x Note on paths ----------- diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt index 654893286..9ce92de0d 100644 --- a/doc/manual/procs.txt +++ b/doc/manual/procs.txt @@ -129,9 +129,9 @@ to supply any type of first argument for procedures: .. code-block:: nim - echo("abc".len) # is the same as echo(len("abc")) - echo("abc".toUpper()) - echo({'a', 'b', 'c'}.card) + echo "abc".len # is the same as echo len "abc" + echo "abc".toUpper() + echo {'a', 'b', 'c'}.card stdout.writeLine("Hallo") # the same as writeLine(stdout, "Hallo") Another way to look at the method call syntax is that it provides the missing @@ -486,7 +486,7 @@ state are automatically saved between calls. Example: inc(i) for ch in items("hello world"): # `ch` is an iteration variable - echo(ch) + echo ch The compiler generates code as if the programmer would have written this: @@ -494,7 +494,7 @@ The compiler generates code as if the programmer would have written this: var i = 0 while i < len(a): var ch = a[i] - echo(ch) + echo ch inc(i) If the iterator yields a tuple, there can be as many iteration variables diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt index 59f7eef55..83852b1ff 100644 --- a/doc/manual/stmts.txt +++ b/doc/manual/stmts.txt @@ -234,11 +234,11 @@ Example: var name = readLine(stdin) if name == "Andreas": - echo("What a nice name!") + echo "What a nice name!" elif name == "": - echo("Don't you have a name?") + echo "Don't you have a name?" else: - echo("Boring name...") + echo "Boring name..." The ``if`` statement is a simple way to make a branch in the control flow: The expression after the keyword ``if`` is evaluated, if it is true @@ -269,17 +269,17 @@ Example: case readline(stdin) of "delete-everything", "restart-computer": - echo("permission denied") - of "go-for-a-walk": echo("please yourself") - else: echo("unknown command") + echo "permission denied" + of "go-for-a-walk": echo "please yourself" + else: echo "unknown command" # indentation of the branches is also allowed; and so is an optional colon # after the selecting expression: case readline(stdin): of "delete-everything", "restart-computer": - echo("permission denied") - of "go-for-a-walk": echo("please yourself") - else: echo("unknown command") + echo "permission denied" + of "go-for-a-walk": echo "please yourself" + else: echo "unknown command" The ``case`` statement is similar to the if statement, but it represents @@ -326,13 +326,13 @@ Example: .. code-block:: nim when sizeof(int) == 2: - echo("running on a 16 bit system!") + echo "running on a 16 bit system!" elif sizeof(int) == 4: - echo("running on a 32 bit system!") + echo "running on a 32 bit system!" elif sizeof(int) == 8: - echo("running on a 64 bit system!") + echo "running on a 64 bit system!" else: - echo("cannot happen!") + echo "cannot happen!" The ``when`` statement is almost identical to the ``if`` statement with some exceptions: @@ -435,7 +435,7 @@ Example: if a[j][i] == 7: found = true break myblock # leave the block, in this case both for-loops - echo(found) + echo found The block statement is a means to group statements to a (named) ``block``. Inside the block, the ``break`` statement is allowed to leave the block @@ -462,10 +462,10 @@ While statement Example: .. code-block:: nim - echo("Please tell me your password: \n") + echo "Please tell me your password: \n" var pw = readLine(stdin) while pw != "12345": - echo("Wrong password! Next try: \n") + echo "Wrong password! Next try: \n" pw = readLine(stdin) diff --git a/doc/manual/types.txt b/doc/manual/types.txt index babf3286f..a1596bcea 100644 --- a/doc/manual/types.txt +++ b/doc/manual/types.txt @@ -546,7 +546,7 @@ so that the builtin ``echo`` proc does what is expected: .. code-block:: nim proc echo*(x: varargs[expr, `$`]) {...} - echo(@[1, 2, 3]) + echo @[1, 2, 3] # prints "@[1, 2, 3]" and not "123" |