Browse Source

Ensure that root types cannot be directly created

Samuel W. Flint 5 years ago
parent
commit
e6e0d88c6b
1 changed files with 12 additions and 0 deletions
  1. 12 0
      larcs.org

+ 12 - 0
larcs.org

@@ -82,6 +82,10 @@ Evaluability is the most complex of these properties, it is accomplished with ~e
   @export
   (defclass <expression> () ())
 
+  (defmethod make-instance ((class (eql '<expression>)) &key &allow-other-keys)
+    (error "Cannot create instance of `~a'."
+           class))
+
   @export
   (defgeneric atomicp (expression))
 
@@ -185,6 +189,10 @@ Of the various types, there are three atomic types, ~<number>~, ~<variable>~ and
   @export
   (defclass <atomic> (<expression>) ())
 
+  (defmethod make-instance ((class (eql '<atomic>)) &key &allow-other-keys)
+    (error "Cannot create instance of `~a'."
+           class))
+
   @export
   (defgeneric value (expression &key resolve-constants))
 
@@ -324,6 +332,10 @@ Compound types are the majority of expressions.  An atom is well and good, but o
   @export
   (defclass <compound> (<expression>) ())
 
+  (defmethod make-instance ((class (eql '<compound>)) &key &allow-other-keys)
+    (error "Cannot create instance of `~a'."
+           class))
+
   (defmethod atomicp ((expression <compound>))
     (declare (ignore expression))
     nil)