added toOpenArray builtin for zero-copy slices; syntax sugar yet to come

This commit is contained in:
Araq 2018-03-24 20:26:20 +01:00
commit 1d9343080d
6 changed files with 84 additions and 14 deletions

View file

@ -1,5 +1,17 @@
discard """
output:""
output:'''1
1
2
3
11
12
13
14
15
2
3
4
'''
"""
# check high/low implementations
@ -20,3 +32,18 @@ doAssert high(float64) > low(float64)
# bug #6710
var s = @[1]
s.delete(0)
proc foo(a: openArray[int]) =
for x in a: echo x
foo(toOpenArray([1, 2, 3], 0, 0))
foo(toOpenArray([1, 2, 3], 0, 2))
var arr: array[8..12, int] = [11, 12, 13, 14, 15]
foo(toOpenArray(arr, 8, 12))
var seqq = @[1, 2, 3, 4, 5]
foo(toOpenArray(seqq, 1, 3))