diff options
author | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-01-06 20:52:30 +0100 |
---|---|---|
committer | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-01-15 22:23:23 +0100 |
commit | 63ab238f5d00a7d4c9501ae635efcbb28f2e4e1a (patch) | |
tree | feb15faee87519c18b179296ad2ce1cc62626cdf /doc | |
parent | 7aa263bebf946339a71cb7d153ea98d3c8302839 (diff) | |
download | Nim-63ab238f5d00a7d4c9501ae635efcbb28f2e4e1a.tar.gz |
Adds note about conflicts with using as a statement.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual.txt b/doc/manual.txt index d9849f044..c8b1c079c 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2257,6 +2257,24 @@ from different modules having the same name. import windows, sdl using sdl.SetTimer +Note that ``using`` only *adds* to the current context, it doesn't remove or +replace, **neither** does it create a new scope. What this means is that if you +apply this to multiple variables the compiler will find conflicts in what +variable to use: + +.. code-block:: nimrod + var a, b = "kill it" + using a + add(" with fire") + using b + add(" with water") + echo a + echo b + +When the compiler reaches the second ``add`` call, both ``a`` and ``b`` could +be used with the proc, so you get ``Error: expression '(a|b)' has no type (or +is ambiguous)``. To solve this you would need to nest ``using`` with a +``block`` statement so as to control the reach of the ``using`` statement. If expression ------------- |