diff options
author | Araq <rumpf_a@web.de> | 2012-02-12 18:25:40 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-02-12 18:25:40 +0100 |
commit | 843ef48808ee86ec3a0b9ebcd318323797449de5 (patch) | |
tree | 75db44e6dd6c964190cac1452faf57f6d528f310 | |
parent | 74498d616eaae30605d7323254c46f5af4ae253c (diff) | |
download | Nim-843ef48808ee86ec3a0b9ebcd318323797449de5.tar.gz |
system.shallow documented
-rwxr-xr-x | doc/nimrodc.txt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/nimrodc.txt b/doc/nimrodc.txt index 58cfa22f6..77a96ee74 100755 --- a/doc/nimrodc.txt +++ b/doc/nimrodc.txt @@ -419,6 +419,18 @@ For ``let`` symbols a copy is not always necessary: let s = varA # may only copy a pointer if it safe to do so +If you know what you're doing, you can also mark single string (or sequence) +objects as `shallow`:idx:\: + +.. code-block:: Nimrod + var s = "abc" + shallow(s) # mark 's' as shallow string + var x = s # now might does not copy the string! + +Usage of ``shallow`` is always safe once you know the string won't be modified +anymore, similar to Ruby's `freeze`:idx:. + + The compiler optimizes string case statements: A hashing scheme is used for them if several different string constants are used. So code like this is reasonably efficient: |