LISTING FOR >udd>sm>ds>w>ml>lisp_defstruct_ COMPILED BY Multics LISP Compiler, Version 2.13c, July 11, 1983 ON 05/05/00 1835.1 mdt Fri IN BEHALF OF Schroth.SysMaint.m ;;; ************************************************************** ;;; * * ;;; * Copyright, (C) Massachusetts Institute of Technology, 1982 * ;;; * * ;;; ************************************************************** ;;; -*- Mode:Lisp; Package:SI; Lowercase:True -*- ;;; ** (c) Copyright 1980 Massachusetts Institute of Technology ** ;;; ** (c) Copyright 1981 Massachusetts Institute of Technology ** ;The master copy of this file is in MC:ALAN;NSTRUCT > ;The current PDP10 MacLisp copy is in MC:ALAN;STRUCT > ;The current Lisp machine copy is in AI:LISPM2;STRUCT > ;The current Multics MacLisp copy is in >udd>Mathlab>Bawden>defstruct.lisp ; on MIT-Multics ;The current VMS-NIL copy is in [NIL.SRC.SPEC]STRUCT.LSP on HTJR ;***** READ THIS PLEASE! ***** ;If you are thinking of munging anything in this file you might want to ;consider finding me (ALAN) and asking me to mung it for you. There is more ;than one copy of this file in the world (it runs in PDP10 and Multics MacLisp, ;NIL, Franz, PSL and on LispMachines) and whatever amazing features you are ;considering adding might be usefull to those people as well. If you still ;cannot contain yourself long enough to find me, AT LEAST send me a piece of ;mail describing what you did and why. Thanks for reading this flame. ; Alan Bawden (ALAN@MC) (eval-when (eval compile) (sstatus nofeature MacLisp-10)) (%include sharpsign) (%include defmacro) (%include other_other) (%include defstruct) (declare (genprefix defstruct-internal-) (*expr dpb ldb) (macros t)) (eval-when (eval compile) (setsyntax #/: (ascii #\space) nil)) (eval-when (eval compile load) #+MacLisp (defun defstruct-retry-keyword (x) (let ((l (exploden x))) (if (= (car l) #/:) (implode (cdr l)) x))) #+LispM (defun defstruct-retry-keyword (x) (intern (get-pname x) si:pkg-user-package)) #+NIL (defmacro defstruct-retry-keyword (x) `(to-keyword ,x)) );End of eval-when (eval compile load) ;;; Eval this before attempting incremental compilation (eval-when (eval compile) #+MacLisp-10 (defmacro append-symbols args (do ((l (reverse args) (cdr l)) (x) (a nil (if (or (atom x) (not (eq (car x) 'quote))) (if (null a) `(exploden ,x) `(nconc (exploden ,x) ,a)) (let ((l (exploden (cadr x)))) (cond ((null a) `',l) ((= 1 (length l)) `(cons ,(car l) ,a)) (t `(append ',l ,a))))))) ((null l) `(implode ,a)) (setq x (car l)))) #+Multics (defmacro append-symbols args `(make_atom (catenate ,@args))) #+LispM (defmacro append-symbols args `(intern (string-append ,@args))) #+NIL (defmacro append-symbols args `(symbolconc ,@args)) (defmacro defstruct-putprop (sym val ind) `(push `(defprop ,,sym ,,val ,,ind) returns)) #+Multics ;;;lcp gobbles (defprop ... macro) at compile time, so we have to use ;;;putprop to be certain macro definitions make it into the object: (defmacro defstruct-put-macro (sym fcn) `(push `(putprop ',,sym ',,fcn 'macro) returns)) #+MacLisp-10 (defmacro defstruct-put-macro (sym fcn) `(push `(defprop ,,sym ,,fcn macro) returns)) #+LispM (defmacro defstruct-put-macro (sym fcn) (setq fcn (if (and (not (atom fcn)) (eq (car fcn) 'quote)) `'(macro . ,(cadr fcn)) `(cons 'macro ,fcn))) `(push `(fdefine ',,sym ',,fcn t) returns)) #+NIL (defmacro defstruct-put-macro (sym fcn) `(push `(add-macro-definition ',,sym ',,fcn) returns)) (defmacro make-empty () `'%%defstruct-empty%%) (defmacro emptyp (x) `(eq ,x '%%defstruct-empty%%)) ;;;Here we must deal with the fact that error reporting works ;;;differently everywhere! #+MacLisp-10 ;;;first arg is ALWAYS a symbol or a quoted symbol: (defmacro defstruct-error (message &rest args) (let* ((chars (nconc (exploden (if (atom message) message (cadr message))) '(#/.))) ;"Bad frob" => "Bad frob." (new-message (maknam (if (null args) chars (let ((c (car chars))) ;"Bad frob." => "-- bad frob." (or (< c #/A) (> c #/Z) (rplaca chars (+ c #o40))) (append '(#/- #/- #\space) chars)))))) `(error ',new-message ,@(cond ((null args) `()) ((null (cdr args)) `(,(car args))) (t `((list ,@args))))))) #+Multics ;;;first arg is ALWAYS a string: (defmacro defstruct-error (message &rest args) `(error ,(catenate "defstruct: " message (if (null args) "." ": ")) ,@(cond ((null args) `()) ((null (cdr args)) `(,(car args))) (t `((list ,@args)))))) #+(or LispM NIL) ;;;first arg is ALWAYS a string: (defmacro defstruct-error (message &rest args) (do ((l args (cdr l)) (fs "") (na nil)) ((null l) `(ferror nil ,(string-append message (if (null args) "." (string-append ":" fs))) ,.(nreverse na))) (cond ((and (not (atom (car l))) (eq (caar l) 'quote) (symbolp (cadar l))) (setq fs (string-append fs " " (string-downcase (cadar l))))) (t (push (car l) na) (setq fs (string-append fs " ~S")))))) );End of eval-when (eval compile) ;;;If you mung the the ordering af any of the slots in this structure, ;;;be sure to change the version slot and the definition of the function ;;;get-defstruct-description. Munging the defstruct-slot-description ;;;structure should also cause you to change the version "number" in this ;;;manner. (defstruct (defstruct-description (:type :list) (:default-pointer description) (:conc-name defstruct-description-) (:alterant ()) #+stingy-defstruct (:eval-when (eval compile))) (version 'one) type dummy ;used to be the displace function slot-alist named-p constructors (default-pointer nil) (but-first nil) size (property-alist nil) ;;end of "expand-time" slots name include (initial-offset 0) (eval-when '(eval compile load)) alterant (conc-name nil) (callable-accessors #-(or LispM NIL) nil #+(or LispM NIL) t) (size-macro nil) (size-symbol nil) (predicate nil) (copier nil) (print nil) ) (defun get-defstruct-description (name) (let ((description (get name 'defstruct-description))) (cond ((null description) (defstruct-error "A structure with this name has not been defined" name)) ((not (eq (defstruct-description-version) 'one)) (defstruct-error "The internal description of this structure is incompatible with the currently loaded version of defstruct, you will need to recompile its definition" name)) (t description)))) ;;;See note above defstruct-description structure before munging this one. (defstruct (defstruct-slot-description (:type :list) (:default-pointer slot-description) (:conc-name defstruct-slot-description-) (:alterant ()) #+stingy-defstruct (:eval-when (eval compile))) number (ppss nil) init-code (type 'notype) (property-alist nil) ref-macro-name ) ;;;Perhaps this structure wants a version slot too? (defstruct (defstruct-type-description (:type :list) (:default-pointer type-description) (:conc-name defstruct-type-description-) (:alterant ()) #+stingy-defstruct (:eval-when (eval compile))) ref-expander ref-no-args cons-expander cons-flavor (cons-keywords nil) (named-type nil) (overhead 0) (defstruct-expander nil) (predicate nil) (copier nil) ) ;; (DEFSTRUCT ( . ) . ) or (DEFSTRUCT . ) ;; ;; is of the form (