public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* checked in vector re-write
@ 2015-08-01  6:16 Per Bothner
  0 siblings, 0 replies; only message in thread
From: Per Bothner @ 2015-08-01  6:16 UTC (permalink / raw)
  To: Kawa mailing list

I just checked in a major re-write of the underlying code for
vectors, strings, and uniform vectors.

The basic idea is to efficiently support vector-indexes, as in APL:

For example:
#|kawa:1|# (! vec1 (vector 'A 'B 'C 'D 'E 'F))
#|kawa:2|# (vec1 [3 5 2])
#(D F C)

The range [2 <: 6] is (roughly) the same as [2 3 4 5]:
#|kawa:3|# (vec1 [2 <: 6])
#(C D E F)

(Th '<:' is a keyword; the '<' is a mnemonic for the
the set of integers '<' the end value 6.  You can also use <=:.)

A range is different from a vector integer in that you can use
a range as the index in the LHS of a set!:

#|kawa:4|# (set! (vec1 [2 <: 4]) #(a b c d e))
#|kawa:5|# vec1
#(A B a b c d e E F)

Notice how the number of replaced elements can be different
then the(! str1  number of elements in the replacement value.
I.e. you can do insertion and deletion this way.
The vector automatically converts to a "gap vector".

This also works for strings:

#|kawa:7|# (! str1 (string-copy "ABCDEF"))
#|kawa:8|# (set! (str1 [2 <: 5]) "98")
AB98F

The internal data structures have changed a lot but I won't go into details here.
It's worth mentining that the changes enable better type inference, and better
support of vectors of primitive types (uniform vectors) without object allocation.

These changes aren't as polished and optimized as I would like, but I needed to check
them in so I can focus on something else (for the JVM languages summit, where
I'll be giving a workshop).
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-01  6:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-01  6:16 checked in vector re-write Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).