Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing function as argument

0 views
Skip to first unread message

Gideon Kay

unread,
Mar 26, 2000, 3:00:00 AM3/26/00
to
I am trying to pass a function name as an argument and am getting an error
regarding "global function".

The function is for example:

(defun is-also-true (m)
(every #'its-true (produce-result-column #'m *three*)))

where m is a function name.

Any ideas?

Thanks

Gideon
gideo...@virgin.net


Pierre R. Mai

unread,
Mar 27, 2000, 3:00:00 AM3/27/00
to
"Gideon Kay" <g...@virgin.net> writes:

> I am trying to pass a function name as an argument and am getting an error
> regarding "global function".
>
> The function is for example:
>
> (defun is-also-true (m)
> (every #'its-true (produce-result-column #'m *three*)))
>
> where m is a function name.

You are confused as to the use of #' or (function x). It is used to
"convert" a name that is lexically or globally apparent into the
function value of that name.

You are just passing on the value of m (which might be the name of a
global function, or a (possibly lexical) function itself) that is
passed into your function. So there is no need to "convert" again:

(defun is-also-true (m)
(every #'its-true (produce-result-column m *three*)))

Then you can call is-also-true with either a symbol that denotes a
global function, or with a proper function, as usual:

(defun use-it ()
(flet ((mypred (x) (> x 10)))
(is-also-true 'evenp)
(is-also-true #'evenp)
(is-also-tue #'mypred)))

Regs, Pierre.

--
Pierre Mai <pm...@acm.org> PGP and GPG keys at your nearest Keyserver
"One smaller motivation which, in part, stems from altruism is Microsoft-
bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]

0 new messages