mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 04:57:49 +00:00
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
This commit is contained in:
@@ -37,7 +37,7 @@ that contains GC'ed memory (``string``, ``seq``, ``ref`` or a closure) either
|
||||
directly or indirectly through a call to a GC unsafe proc.
|
||||
|
||||
The `gcsafe`:idx: annotation can be used to mark a proc to be gcsafe,
|
||||
otherwise this property is inferred by the compiler. Note that ``noSideEfect``
|
||||
otherwise this property is inferred by the compiler. Note that ``noSideEffect``
|
||||
implies ``gcsafe``. The only way to create a thread is via ``spawn`` or
|
||||
``createThead``. ``spawn`` is usually the preferable method. Either way
|
||||
the invoked proc must not use ``var`` parameters nor must any of its parameters
|
||||
@@ -146,7 +146,7 @@ wait on multiple flow variables at the same time:
|
||||
|
||||
# wait until 2 out of 3 servers received the update:
|
||||
proc main =
|
||||
var responses = newSeq[RawFlowVar](3)
|
||||
var responses = newSeq[FlowVarBase](3)
|
||||
for i in 0..2:
|
||||
responses[i] = spawn tellServer(Update, "key", "value")
|
||||
var index = awaitAny(responses)
|
||||
|
||||
@@ -33,7 +33,7 @@ variables at the same time:
|
||||
|
||||
# wait until 2 out of 3 servers received the update:
|
||||
proc main =
|
||||
var responses = newSeq[RawFlowVar](3)
|
||||
var responses = newSeq[FlowVarBase](3)
|
||||
for i in 0..2:
|
||||
responses[i] = spawn tellServer(Update, "key", "value")
|
||||
var index = awaitAny(responses)
|
||||
|
||||
@@ -1325,7 +1325,7 @@ define operators which accept Slice objects to define ranges.
|
||||
b = "Slices are useless."
|
||||
|
||||
echo a[7..12] # --> 'a prog'
|
||||
b[11.. -2] = "useful"
|
||||
b[11.. ^2] = "useful"
|
||||
echo b # --> 'Slices are useful.'
|
||||
|
||||
In the previous example slices are used to modify a part of a string, and even
|
||||
|
||||
@@ -210,8 +210,7 @@ template sortedByIt*(seq1, op: expr): expr =
|
||||
## p2: Person = (name: "p2", age: 20)
|
||||
## p3: Person = (name: "p3", age: 30)
|
||||
## p4: Person = (name: "p4", age: 30)
|
||||
##
|
||||
## people = @[p1,p2,p4,p3]
|
||||
## people = @[p1,p2,p4,p3]
|
||||
##
|
||||
## echo people.sortedByIt(it.name)
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user