From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harald Hanche-Olsen Newsgroups: gmane.emacs.help Subject: Re: elisp: can a function/defun return two strings..? prompt for two strings?? Date: Sun, 27 Feb 2011 11:31:22 +0100 Organization: Norwegian university of science and technology Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1298803246 24025 80.91.229.12 (27 Feb 2011 10:40:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 Feb 2011 10:40:46 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 27 11:40:42 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pte3O-0000fS-3t for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 11:40:42 +0100 Original-Received: from localhost ([127.0.0.1]:58677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pte3N-00050K-G0 for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 05:40:41 -0500 Original-Path: usenet.stanford.edu!news-transit.tcx.org.uk!news2.arglkargh.de!newsfeed.straub-nv.de!newsfeed1.swip.net!uio.no!ntnu.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 23 Original-NNTP-Posting-Host: euler.math.ntnu.no Original-X-Trace: orkan.itea.ntnu.no 1298802683 22006 129.241.15.89 (27 Feb 2011 10:31:23 GMT) Original-X-Complaints-To: usenet@ntnu.no Original-NNTP-Posting-Date: Sun, 27 Feb 2011 10:31:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (darwin) Cancel-Lock: sha1:fA2w78Gz28hLwrwA53u8M+YqehM= Original-Xref: usenet.stanford.edu gnu.emacs.help:185365 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79522 Archived-At: [ken ] > So how to "return" two variables to a calling function, possibly have to > prompt for one or both of them? (I can think of a half dozen ways to do > this in C, but this is elisp.) Since elisp doesn't have multiple return values (as Common Lisp does), you'll have to wrap the two return values in a single item. A cons cell or a list are the most likely choices: (cons v1 v2) ; retreive using car and cdr (list v1 v2) ; retreive using car and cadr As an alternative, if most of the functions that will be using this only need the first value, your function might just return v1 after first assigning v2 to some variable that interested callers can access. But I find that slightly distasteful. -- * Harald Hanche-Olsen - It is undesirable to believe a proposition when there is no ground whatsoever for supposing it is true. -- Bertrand Russell