mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
* spec for view types * spec additions * refactoring; there are two different kinds of views * refactorings and spec additions * enforce that view types are initialized * enforce borrowing from the first formal parameter * enforce lifetimes for borrowing of locals * typo in the manual * clarify in the implementation what a borrow operation really is
29 lines
323 B
Nim
29 lines
323 B
Nim
discard """
|
|
output: '''11
|
|
22
|
|
33
|
|
3
|
|
2
|
|
3
|
|
3'''
|
|
targets: "c cpp"
|
|
"""
|
|
|
|
{.experimental: "views".}
|
|
|
|
proc take(a: openArray[int]) =
|
|
echo a.len
|
|
|
|
proc main(s: seq[int]) =
|
|
var x: openArray[int] = s
|
|
for i in 0 .. high(x):
|
|
echo x[i]
|
|
take(x)
|
|
|
|
take(x.toOpenArray(0, 1))
|
|
let y = x
|
|
take y
|
|
take x
|
|
|
|
main(@[11, 22, 33])
|