TypesSpec

Overview

This topic discusses how the Common Lisp Types are implemented in CLforJava. In Common Lisp a data type is a set of Lisp objects. Many Lisp objects belong to more than one such set. In this way, it doesn't make sense to ask what is the "type" of an object, but whether an object belongs to a given type. The data types defined in Common Lisp are arranged into a hierarchial TypeSystem (actually a paratial order) defined by the subset relationship.

Current Proposal

In Java there is no way to support multiple inheritance for the Types we are to implement in a hierarchial structure. The current proposal is to create an interface for each Type that extends from its derived type. Inside of each type's interface a static final typeName is defined creating a new instance of that type using a Factory method. See DesignPatternUsage.

Here is an example of an interface for the Common Lisp type Atom:

public interface Atom extends T {

  public static final Symbol typeName = Symbol.Factory.newInstace("ATOM", "COMMON-LISP");
 
}   

Type Specifications and Implementation (-- add link to Hyperspec)

Type specifications in CLforJava are powerful and somewhat confusing. It is important to understand the difference from the runtime type of a Lisp object and its membership in a set defined by one or more type specifications. For example, at runtime the value of a symbol may be 42. Its inherent type (if you use TYPE-OF) in this example would be FIXNUM. It may be a member of the following types defined by various type specifications:
  • (integer 0 64)
  • (member (7 21 42 126))
  • (or integer poodle-boutique)
  • (not string)
  • (satisfies evenp)
  • and a small infinity of other sets

Implementing Types

TBD (Java interfaces, instanceof)

Implementing Type Testing

(inline - (declare (mumble (integer 0 10)) (deftype - compile to function1)

References

HyperSpec CLtL
link 1 Link 2

Implementation

Details of implementation

Core Java Classes Javadoc Links

Discussions

Links to Blog issues

Current Status of TypesSpec

Status:

Basic type system implemented in the Java interface structure. Basic pattern defined.

Spring 2003 Semester

The latest specification deliberations of Common Lisp have defined a new Lisp type: Boolean. This is a subtype of Symbol. It's only subtype is Null. The type Boolean has exactly 1 direct instance which is the symbol T. This must be implemented by the team during this semester. The definition of T should follow the definition of NIL as a singleton instance.

Release Level:

Open bug count:

Test Suites

Links to JUnit results

-- JerryBoetje - 12 Jul 2003

Topic attachments
I Attachment Action Size Date Who Comment
PDFpdf TypeSystem.pdf manage 1097.9 K 2004-08-31 - 14:21 JerryBoetje Type System Presentation
Topic revision: r10 - 2009-03-11 - 20:26:23 - MadelineWilliams
 
Home
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback