That's a long discussion but I find it missing concrete examples. Let it be
more clear on a fake example. Imagine there's a Bag[string, T] data structure
implemented with a binary tree, like the following where we have stored some
data keyed by the words from "Some people don't read the RFCs":
bag
|
+---------------------+-------------------+
| |
+----------------+--------------+
+---------+-----+
| | |
|
+-------+--------+ +------+------+ +--------+
+-------+
| | | | | #5 | |
#6 |
+---------+ +----------+ +--------+ +--------+ | "Some" | |
"the" |
| #1 | | #2 | | #3 | | #4 | +--------+
+-------+
| "don't" | | "people" | | "read" | | "RFCs" |
+---------+ +----------+ +--------+ +--------+
Run
The index of an item in the Bag is denoted #index while the keys are the string
words, and the values are not represented.
Your RFC proposal is to offer a new syntax depending on the type of access:
# Read the value in the "read" node.
let r: T = bag{"read"}
# Update value in the "Some" node.
bag{"Some"} = ...new T data value...
# Read the value of the 2nd node, i.e. the "people" one.
let v: T = bag[2]
# Change the value of the 4th node, i.e. the "RFCs" one.
bag[4] = ...other T value...
# Get the values in nodes 3 to 5, i.e. "Read", "RFCs" and "Some".
let s: seq[T] = bag[3 .. 5]
Run
The proposed {} syntax is used to access data by key in containers while the []
syntax is used to access data by position.
This allows querying the data by index range like the last line shows.
This proposal would require to change the way items are accessed in Table for a
transition period.
Is it a good summary of the RFC?