[Kst] Indexed access into vectors ?

George Staikos staikos at kde.org
Tue Jul 5 17:48:35 CEST 2005


On Friday 01 July 2005 09:46, Brisset, Nicolas wrote:
> > > I was wondering whether it is already possible in
> >
> > expressions (as used
> >
> > > in equations) to access the nth element of a given data vector ?
> >
> >   The plan is to support this at some point, but I have no
> > idea what notation to use.  [vector[n]] seems ugly but should
> > be parseable.  [vector(n)] interferes with function calls.
> > [vector{n}] is unusual.  [vector][n] is impossible to
> > distinguish from a possibly common parse error ( != [v1]*[v2]).
>
> I understand that square brackets [] should only be used to delimit
> vector names, not to group expressions for precedence or whatever reason
> , which should be achieved with parentheses. If that is correct, I do
> not think there are cases where parentheses *inside* square brackets
> could be used for function calls. Hence, [vector(n)] seems right to me,
> i.e. fairly intuitive and reliably parseable :-)

  The problem is that you can do function calls.  [=vector(n)] would be a 
function call.  The case of parsing differently based on if there is an = in 
the reference is a big problem because it basically requires two completely 
different parsers.  It's also confusing to look at since it means something 
different in different cases.

  The only form of brackets we have unused is {} but that's a bit unorthodox 
for indexing vectors.  We also want the ability to do subvectors I think.

  How about something like  @vector[index]  @vector[range]  
@vector[range,index,range,range,index,...] ?

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/



More information about the Kst mailing list