STELLA - Painless Symbolic Processing in C++

Robert MacGregor
USC/Information Sciences Institute, [email protected]

What is STELLA?

STELLA is an object-oriented programming language that STELLA programs compile into Benefits:

Design Rationale

The design of STELLA was guided by the following requirements:

We have Succeeded!

(''strongly-typed Lisp'' is not an oxymoron)

A Few Features Aren't Finished

STELLA still needs:

Method Example #1

STELLA:
(defmethod (length INTEGER) ((self CONS))
  :documentation "Return the length of the CONS list 'self'.
                 CAUTION: Breaks if 'self' is not the head
                 of a CONS list."
  (let ((cons self)
        (i 0))
    (while (non-empty? cons)
      (++ i)
      (setq cons (rest cons)))
    (return i) ))
C++:
int Cons::length () {
 {
    Cons* cons = this;
    int i = 0;

    while (cons->non_emptyP()) {
      i = i + 1;
      cons = cons->rest;
    }
    return (i);
  }
}

Method Example #2:

STELLA:
(defmethod (member? BOOLEAN) ((self CONS) (object OBJECT))
  :documentation "Return TRUE iff 'object' is a member of
                  the cons list 'self'.  Uses an 'eql?' test."
  (foreach element in self
           where (eql? element object)
           do (return TRUE))
  (return FALSE) )
C++:
boolean Cons::memberP (Object* object) {
 {
    Object* element = NULL;
    Cons* iter_001 = this;

    while (!nilP(iter_001)) {
      element = iter_001->value;
      iter_001 = iter_001->rest;
      if (element == object) {
        return (TRUE);
      }
    }
  }
  return (FALSE);
}

Class Example #1

STELLA:
(defclass CONS (STANDARD-OBJECT)
  :parameters ((any-value :type OBJECT))
  :slots
  ((value :type (LIKE (any-value self)) :public? TRUE)
   (rest :type (CONS OF (LIKE (any-value self)))
         :public? TRUE
         :initially NIL)))
C++:
class Cons : public Standard_Object {
public:
  Object* value;
  Cons* rest;
public:
  virtual int length();
  virtual Cons* reverse();
  virtual Object* first();
  virtual Object* second();
  virtual Object* third();
       ....
  virtual boolean memberP(Object* object);
}

Class Example #2

STELLA:
(defclass MAPPABLE-OBJECT (STANDARD-OBJECT DYNAMIC-SLOTS-MIXIN)
  :documentation "Enables the definition of projections."
  :abstract? TRUE
  :slots
  ((native-name :type STRING :allocation :dynamic
                :documentation "Used when native name cannot be a symbol.")))
C++:
class Mappable_Object : public Standard_Object,
                        public Dynamic_Slots_Mixin {
public:
  virtual String_Wrapper* wrapped_native_name_setter(String_Wrapper* value);
  virtual String_Wrapper* wrapped_native_name();
};

String_Wrapper* Mappable_Object::wrapped_native_name () {
 { char* barevalue =
          ((String_Wrapper*)
             (dynamic_slot_value(this,
                   SYM_KERNEL_NATIVE_NAME,
                   NULL_STRING_WRAPPER)))->wrapper_value;
    return (((barevalue != NULL) ?
             string_wrap_literal(barevalue) : NULL));
  }
}

STELLA vs. Common Lisp/CLOS

STELLA variations (mostly due to limitations of C++): STELLA does not have:

STELLA vs. C++

STELLA variations:

Support for Symbolic Processing

Writing an interpreter (e.g., a query processor) requires: C++ has none of these built-in, so STELLA adds them. These same features make it easier to write GUI interfaces.

Writing a translator, using the ``program-as-data'' paradigm, requires something equivalent to:

STELLA adds these also.

STELLA's Triggers (``Demons'')

A demon can monitor: Interpreted slot accessors (get-value, put-value, drop-value) are used to program a demon.

Only an ''active'' slot/class can have demons, non-active slots incur no overhead.

Demons can be activated and deactivated at run-time.


Why a new language, why not just extend C++?

Some STELLA features (e.g., iterators, symbols) could be implemented using libraries and C++ macros.

Many STELLA features (critical for rapid prototyping) could not be implemented even with a powerful macro facility. Their implementation requires type inference and/or two-pass compilation:

Many STELLA features (e.g., funcallable slot accessors, default values, dynamic slot allocation, foreach loops) are implemented using the program-as-data paradigm (backquote). Implementing them directly in C++ is not impossible, just inordinately difficult.

Conclusions

The STELLA translator was worth building: The notion of a strongly-typed Lisp makes sense.

Automatic generation of efficient, readable C++ is feasible.

Translation to other object-oriented languages (e.g., Java) would not be difficult.


PowerLoom

PowerLoom is the successor to the Loom® knowledge representation system.

PowerLoom features:

PowerLoom is being implemented in STELLA.

PowerLoom Components


First PowerLoom Release

The first release of PowerLoom will implement a fully functional KBMS.

First release features:

Estimated release date: December, '96.
Loom and PowerLoom are registered trademarks of the University of Southern California.
Last modified: Sep 26, 1996