Ignore:
Timestamp:
05/27/05 12:18:28 (16 years ago)
Author:
piso
Message:

Support keyword parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/deftype.lisp

    r9266 r9267  
    22;;;
    33;;; Copyright (C) 2004-2005 Peter Graves
    4 ;;; $Id: deftype.lisp,v 1.6 2005-05-27 11:43:06 piso Exp $
     4;;; $Id: deftype.lisp,v 1.7 2005-05-27 12:18:28 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    2121
    2222(defmacro deftype (name lambda-list &rest body)
    23   ;; Optional parameters default to * rather than NIL.
    24   ;; FIXME Extend this code to handle keyword parameters too!
    25   (when (memq '&optional lambda-list)
     23  ;; Optional and keyword parameters default to * rather than NIL.
     24  (when (or (memq '&optional lambda-list)
     25            (memq '&key lambda-list))
    2626    (let ((new-lambda-list ())
    27           (optionalp nil))
     27          (state nil))
    2828      (dolist (thing lambda-list)
    29         (cond (optionalp
     29        (cond ((eq thing '&optional)
     30               (setf state '&optional))
     31              ((eq thing '&key)
     32               (setf state '&key))
     33              ((memq thing lambda-list-keywords)
     34               (setf state nil))
     35              ((eq state '&optional)
    3036               (when (symbolp thing)
    3137                 (setf thing (list thing ''*))))
    32               ((eq thing '&optional)
    33                (setf optionalp t))
    34               ((memq thing lambda-list-keywords)
    35                (setf optionalp nil)))
     38              ((eq state '&key)
     39               (when (symbolp thing)
     40                 (setf thing (list thing ''*)))))
    3641        (push thing new-lambda-list))
    3742      (setf lambda-list (nreverse new-lambda-list))))
Note: See TracChangeset for help on using the changeset viewer.