0.6.7.22: removed CVS dollar-Header-dollar tags from sources
[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 (def!macro sb!xc:deftype (name arglist &body body)
13   #!+sb-doc
14   "Define a new type, with syntax like DEFMACRO."
15   (unless (symbolp name)
16     (error "type name not a symbol: ~S" name))
17   (let ((whole (gensym "WHOLE-")))
18     (multiple-value-bind (body local-decs doc)
19         (parse-defmacro arglist whole body name 'deftype :default-default ''*)
20       `(eval-when (:compile-toplevel :load-toplevel :execute)
21          (%compiler-deftype ',name
22                             #'(lambda (,whole)
23                                 ,@local-decs
24                                 (block ,name ,body))
25                             ,@(when doc `(,doc)))))))