Changeset 8452


Ignore:
Timestamp:
02/03/05 02:27:44 (16 years ago)
Author:
piso
Message:

INCF, DECF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/define-modify-macro.lisp

    r4206 r8452  
    11;;; define-modify-macro.lisp
    22;;;
    3 ;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: define-modify-macro.lisp,v 1.1 2003-10-06 00:16:18 piso Exp $
     3;;; Copyright (C) 2003-2005 Peter Graves
     4;;; $Id: define-modify-macro.lisp,v 1.2 2005-02-03 02:27:44 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    7575
    7676(defmacro incf (place &optional (delta 1))
    77   (if (symbolp place)
    78       `(setq ,place (+ ,place ,delta))
    79       `(incf-complex ,place ,delta)))
     77  (cond ((symbolp place)
     78         `(setq ,place (+ ,place ,delta)))
     79        ((and (consp place) (eq (car place) 'THE))
     80         (let ((res (gensym)))
     81           `(let ((,res (the ,(second place) (+ ,place ,delta))))
     82              (setq ,(third place) ,res))))
     83        (t
     84         `(incf-complex ,place ,delta))))
    8085
    8186(defmacro decf (place &optional (delta 1))
    82   (if (symbolp place)
    83       `(setq ,place (- ,place ,delta))
    84       `(decf-complex ,place ,delta)))
     87  (cond ((symbolp place)
     88         `(setq ,place (- ,place ,delta)))
     89        ((and (consp place) (eq (car place) 'THE))
     90         (let ((res (gensym)))
     91           `(let ((,res (the ,(second place) (- ,place ,delta))))
     92              (setq ,(third place) ,res))))
     93        (t
     94         `(decf-complex ,place ,delta))))
Note: See TracChangeset for help on using the changeset viewer.