From: Barry Margolin
Subject: Re: argument passing: defaults
Date: 
Message-ID: <607a7n$of2@pasilla.bbnplanet.com>
In article <·············@WINTERMUTE.eagle>,
SDS  <···········@cctrading.com> wrote:
](defun zz (&optional (a t)) (format t "zz: a: ~a~%" a))
](defun xx (&optional a) (format t "xx: a: ~a~%" a) (zz a))
](xx)
]xx: a: nil
]zz: a: nil
]nil
]
]Quite reasonable. I understand why I am getting this just fine.
]But I want zz to use the default argument! I did not give xx any arg,
]and I don't want zz to get any arg either.
]Is it possible to deal with this without either resorting to *any*
]redefining of zz (I *cannot* put (setq a (or a t)) in zz) or a kludge in
]xx like (if a (zz a) (zz))?

You can make use of the supplied-p argument that can be used with optional
arguments:

(defun xx (&optional (a nil a-supplied-p))
  (format t "~&xx: a: ~A~%" a)
  (if a-supplied-p
      (zz a)
      (zz)))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.