www.delorie.com/gnu/docs/kawa/kawa-tour_8.html   search  
 
Buy GNU books!


Kawa: Compiling Scheme to Java

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7 Collections

Kawa has a rudimentary hierarchy of collection classes.

 
class Sequence {
  abstract public int length();
  abstract public Object elementAt (int index);
  ...
}

A Sequence is the abstract class that includes lists, vectors, and strings.

 
class FString extends Sequence {
  char[] value;
  ...
}

Used to implement fixed-length mutable strings (array of Unicode character). This is used to represent Scheme strings.

 
class FVector extends Sequence {
  Object[] value;
  ...
}
Used to implement fixed-length mutable general one-dimensional array of Object. This is used to represent Scheme vectors.

 
class List extends Sequence {
  protected List () { }
  static public List Empty = new List ();
  ...
}

Used to represent Scheme (linked) lists. The empty list '() is the static (global) value List.Empty. Non-empty-lists are implemented using Pair objects.

 
class Pair extends Sequence {
  public Object car;
  public Object cdr;
  ...
}

Used for Scheme pairs.

 
class PairWithPosition extends Pair {
  ...
}

Like Pair, but includes the filename and linenumber in the file from which the pair was read.

Future plans include more interesting collection classes, such a sequences implemented as a seekable disk file; lazily evaluated sequences; hash tables; APL-style multi-dimensional arrays; stretchy buffers.(1)


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003