unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Harald Hanche-Olsen <hanche@math.ntnu.no>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp: can a function/defun return two strings..? prompt for two strings??
Date: Sun, 27 Feb 2011 11:31:22 +0100	[thread overview]
Message-ID: <pcoaahhhipx.fsf@math.ntnu.no> (raw)
In-Reply-To: mailman.2.1298798656.16925.help-gnu-emacs@gnu.org

[ken <gebser@mousecar.com>]

> 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     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell


       reply	other threads:[~2011-02-27 10:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2.1298798656.16925.help-gnu-emacs@gnu.org>
2011-02-27 10:31 ` Harald Hanche-Olsen [this message]
2011-02-27 11:07 ` elisp: can a function/defun return two strings..? prompt for two strings?? Pascal J. Bourguignon
2011-02-27 21:10 ` Tim X
2011-02-27  9:24 ken
2011-02-27 10:39 ` Andrea Crotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pcoaahhhipx.fsf@math.ntnu.no \
    --to=hanche@math.ntnu.no \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).