system.shallow documented
This commit is contained in:
parent
74498d616e
commit
843ef48808
1 changed files with 12 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue