help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp: can a function/defun return two strings..? prompt for two str


From: Harald Hanche-Olsen
Subject: Re: elisp: can a function/defun return two strings..? prompt for two strings??
Date: Sun, 27 Feb 2011 11:31:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (darwin)

[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 via email to

[Prev in Thread] Current Thread [Next in Thread]