This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
compact vector indexing
- From: Per Bothner <per at bothner dot com>
- To: kawa at sourceware dot org
- Date: Mon, 12 Jun 2006 17:40:08 -0700
- Subject: compact vector indexing
Recently I implemented a compact syntax for indexing Java
arrays using functions-call syntax. I've now extended
this to all vectors, strings, lists and more generally
any object that implements java.util.List:
(arr index) == (invoke arr 'get arr index)
(set! (arr index) value) == (invoke arr 'set index value)
assuming arr implements java.util.List, which Kawa vectors,
uniform vectors, strings, and lists all do.
For example if v is a Scheme vector:
(v i) == (vector-ref v i)
The Kawa compiler can do the transformation at compile time
assuming it knows that arr implements java.util.List.
Future (unimplemented) follow-ons:
* Similar for multi-dimensional arrays:
(arr i1 i2 ...) == (array-ref arr i1 i2 ...) ; Not implemented
* Allow vector indexes, as in APL:
((arr indexes) i) == (arr (indexes i)) ; Not implemented
Assuming indexes is a vector (or more generally anything else
that implements java.util.List. There would be special handling
of integer ranges which is how you'd extract a sub-sequence.
I don't know when I'll get around to doing either of these.
The first one is fairly high priority just for the sake of
consistency.
--
--Per Bothner
per@bothner.com http://per.bothner.com/