aboutsummaryrefslogtreecommitdiff
path: root/src/types.lisp
diff options
context:
space:
mode:
authorThomas Albers Raviola <thomas@thomaslabs.org>2024-05-16 18:31:28 +0200
committerThomas Albers Raviola <thomas@thomaslabs.org>2024-05-16 18:31:28 +0200
commitf19998f7fd9db2bd1ed4eb80ea1744a013b166fa (patch)
treef010bb2afd58bcddfc56b672b8f1532bfa1b446a /src/types.lisp
parentd917f41beca176b8f2b682ac3a2c25b148752b71 (diff)
Define types for primitives instead of using lists
* src/parser.lisp: Add alias for shorting chain calls. First symbol may be outside chain. * src/types.lisp: Remove specialp from closure class
Diffstat (limited to 'src/types.lisp')
-rw-r--r--src/types.lisp48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/types.lisp b/src/types.lisp
index 06183b1..c845b2d 100644
--- a/src/types.lisp
+++ b/src/types.lisp
@@ -31,11 +31,7 @@
(environment :reader closure-environment
:initarg :environment
:type list
- :documentation "")
- (specialp :reader closure-special-p
- :initarg :specialp
- :type boolean
- :documentation "")
+ :documentation "Environment captured by the closure")
(type :reader closure-type
:initarg :type
:type keyword
@@ -45,9 +41,9 @@
:type function
:documentation "")))
-(defun make-closure (function arg-list specialp groupp &optional environment type)
+(defun make-closure (function arg-list groupp &optional environment type)
(make-instance 'closure :function function :arg-list arg-list
- :specialp specialp :groupp groupp
+ :groupp groupp
:environment environment
:type type))
@@ -88,3 +84,41 @@
(defun concat (&rest strings)
(apply #'concatenate 'string strings))
+
+(defclass object ()
+ ((type :reader object-type
+ :initarg :type
+ :type keyword
+ :documentation "")
+ (value :reader object-value
+ :initarg :value
+ :type t
+ :documentation "")))
+
+(defun make-object (type value)
+ (make-instance 'object :type type :value value))
+
+(defun objectp (object)
+ (typep object 'object))
+
+(defun object-symbol-p (object)
+ (and (objectp object) (eq (object-type object) :symbol)))
+
+(defmethod print-object ((object object) stream)
+ (format stream "#<OBJECT :TYPE ~A :VALUE ~A>"
+ (object-type object) (object-value object)))
+
+(defclass chain ()
+ ((links :reader chain-links
+ :initarg :links
+ :type list
+ :documentation "")))
+
+(defun make-chain (links)
+ (make-instance 'chain :links links))
+
+(defun chainp (object)
+ (typep object 'chain))
+
+(defmethod print-object ((object chain) stream)
+ (format stream "#<CHAIN :LINKS ~A>" (chain-links object)))