This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]