From f19998f7fd9db2bd1ed4eb80ea1744a013b166fa Mon Sep 17 00:00:00 2001 From: Thomas Albers Raviola Date: Thu, 16 May 2024 18:31:28 +0200 Subject: 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 --- src/types.lisp | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'src/types.lisp') 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 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 object))) -- cgit v1.2.3