Re: [Tcl9-cloverfield] Vector index references
Status: Alpha
Brought to you by:
fbonnet
From: Frédéric B. <fre...@fr...> - 2009-01-19 10:11:09
|
Hi, ----- "Andy Goth" <unu...@ai...> a écrit : > Today I spent some time contemplating vector index references and how > they can be used. [...] > 2. {index:} > - refers to the empty list "between" index and its predecessor > - if end, refers to the space before the last element > - if zero or negative, refers to the space before the first > element > - if equal to or greater than the list length, refers to the space > after the last element [...] > Examples of {index:}: > > set &var{0:} (W X) -> W X Y Z A b c D E F > set &var(-9:} (V) -> V W X Y Z A b c D E F > set &var{1:} (0 1) -> V 0 1 W X Y Z A b c D E F > set &var{end:} (2 3) -> V 0 1 W X Y Z A b c D E 2 3 F > set &var{end+1:} (G H) -> V 0 1 W X Y Z A b c D E 2 3 F G H > set &var{end+9:} (I) -> V 0 1 W X Y Z A b c D E 2 3 F G H I So you're doing away with insert and replace it with set on a pseudo-index. Interesting, I like the idea. It also unifies insert/replace/append depending on the index and whether the sublist is empty or not. BTW I suppose that for symmetry unset removes elements. However are references to sublists "live"? This is a really big can of worms you're opening there at it implies a lot of bookkeeping. On my side I've worked a bit on the whole concept of vector indexing, and I'm replacing it by the more general concept of "selector" of which flat indexing is the simplest case. More on that later (I'm working on a revision of the syntax). This is also subject to evolve with my progress on the implementation, because I want to keep the syntax and the implementation on par: I don't want to provide features that are too difficult to use (or implement) from C as I want to keep the dual nature of Tcl. So with the concept of selector I can address the various access semantics that usual container classes can provide (the C++ STL is a good start) from both the script and C levels, allowing custom object types to introduce their own indexing methods (e.g XPath for XML elements). So long, Fred |