tmteam / NFun

Expressions Evaluator for .NET
MIT License
57 stars 4 forks source link

Change slices syntax #54

Open tmteam opened 2 years ago

tmteam commented 2 years ago

Current syntax arr[a:b step c] may conflict with inplace :type notation

It has to be solved before release

Candidates:


# [:: step]

a = [1..4][3 :: 5 step 2]
a = [1..4][3 :: ]
a = [1..4][::5]
a = [1..4][step 2]
a = [1..4][3::5]
a = [1..4][3:: step 5]
a = [1..4][::3 step 5]

# [from to step]

a = [1..4][from 3 to 5 step 2]
a = [1..4][from 3]
a = [1..4][to 5]
a = [1..4][step 2]
a = [1..4][from 3 to 5]
a = [1..4][from 3 step 5]
a = [1..4][to 3 step 5]

# [to step]

a = [1..4][3 to 5 step 2]
a = [1..4][3 to]
a = [1..4][to 5]
a = [1..4][step 2]
a = [1..4][3 to 5]
a = [1..4][3 to step 5]
a = [1..4][to 3 step 5]

# [... step]

a = [1..4][3 ... 5 step 2]
a = [1..4][3...]
a = [1..4][...5]
a = [1..4][step 2]
a = [1..4][3...5]
a = [1..4][3... step 5]
a = [1..4][...3 step 5]

# array as slice (madness!)
(array casts to range)
a = [1..4][2]
a = [1..4][2,3,4]
a = [1..4][3..5 step 2]
a = [1..4][3.. ]
a = [1..4][..5]
a = [1..4][step 2]
a = [1..4][3..5]
a = [1..4][3.. step 5]
a = [1..4][..3 step 5]

----------------------------------------
rejected
# ... step

a = [1..4] 3...
a = [1..4] ...5
a = [1..4] step 2
a = [1..4] 3...5
a = [1..4] 3... step 5
a = [1..4] ...3 step 5
a = [1..4] 3 ... 5 step 2

#  from to step

a = [1..4] from 3 to 5 step 2
a = [1..4] from 3
a = [1..4] to 5
a = [1..4] step 2
a = [1..4] from 3 to 5
a = [1..4] from 3 step 5
a = [1..4] to 3 step 5