Initial revision
[sbcl.git] / src / compiler / deftype.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB!IMPL")
11
12 (file-comment
13  "$Header$")
14
15 (defmacro sb!xc:deftype (name arglist &body body)
16   #!+sb-doc
17   "Define a new type, with syntax like DEFMACRO."
18   (unless (symbolp name)
19     (error "type name not a symbol: ~S" name))
20   (let ((whole (gensym "WHOLE-")))
21     (multiple-value-bind (body local-decs doc)
22         (parse-defmacro arglist whole body name 'deftype :default-default ''*)
23       `(eval-when (:compile-toplevel :load-toplevel :execute)
24          (%compiler-deftype ',name
25                             #'(lambda (,whole)
26                                 ,@local-decs
27                                 (block ,name ,body))
28                             ,@(when doc `(,doc)))))))