next up previous
Next: 2.16 Time Up: 2. Environmentally Friendly I/O Previous: 2.14 Strings

  
2.15 Field Selection Syntax for Maps

Pending the design and implementation of a type system for SETL, I have added the convenience of records to SETL (without, alas, the security of strong typing) by extending the member selection (``dot'') notation so that it can be used to address range elements in maps whose domain elements are strings having the form of SETL identifiers. For any single-valued, string-domained map f, the identity *

f.x = f(`x')
holds. The dot also retains its normal purpose of explicitly resolving member names to packages. In a case-insensitive stropping 2.3 regime, F.X, F.x, and f.X are also equivalent to f(`x') and F(`x') (but not f(`X'), i.e. F(`X')).

This small (and admittedly dubious) extension to the meaning of the infix dot, originally intended as a stand-in to allow maps to serve easily as records, proves to be very useful for program-to-program communication. With no preliminary declarations or difficulties about representing records of various types while they are in transit in the I/O system, SETL programs can pass data around as maps, where one field may serve as a discriminant (tag) to indicate which other fields are meaningful. Such flexibility offers more power than discipline, but at least corresponds to familiar practice in JavaScript [152] and resembles the model of ``resources'' in the X windowing system [121], so it can be argued that the pitfalls as well as the strengths of this approach are already fairly well known.


next up previous
Next: 2.16 Time Up: 2. Environmentally Friendly I/O Previous: 2.14 Strings
David Bacon
1999-12-10