From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: How to write specify default values for function arguments? Date: Tue, 01 Oct 2002 17:37:10 -0600 Sender: help-gnu-emacs-admin@gnu.org Message-ID: <3D9A31A6.2030002@ihs.com> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1033515956 4383 127.0.0.1 (1 Oct 2002 23:45:56 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 1 Oct 2002 23:45:56 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17wWi9-00018F-00 for ; Wed, 02 Oct 2002 01:45:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17wWiP-000704-00; Tue, 01 Oct 2002 19:46:09 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!peernews3.colt.net!news0.de.colt.net!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!170.207.51.80!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Original-NNTP-Posting-Host: 170.207.51.80 Original-X-Trace: fu-berlin.de 1033515427 14073053 170.207.51.80 (16 [82742]) User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 X-Accept-Language: en-us Original-Xref: nntp.stanford.edu gnu.emacs.help:105618 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:2163 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2163 Tony wrote: > "gnuist006" wrote in message > news:b00bb831.0210011045.5f29a1b4@posting.google.com... > >>I am looking for multiple ways for >>specifying default values for function arguments >>as you can do in C++. >> >>thanks >> > > use &optional, any parameters left out will be nil. > > (defun foo (required-arg &optional opt1 opt2) > (unless opt1 (setq opt1 default-val-1)) > (unless opt2 (setq opt2 default-val-2)) > ...) Or do it the Common Lisp way: (require 'cl) (defun* foo (required-arg &optional (opt1 default-val-1) (opt2 default-val-2)) ...) -- Kevin Rodgers