From: Doug Nelson
Subject: Functions as arguments in xlisp
Date: 
Message-ID: <6gtpec$orr$1@gte2.gte.net>
Can someone explain to me why the following does not work in xlisp 3.02?

> (defun dof (f a b) (f a b))
dof
> (dof #'+ 2 3)
error: unbound function - f
if continued: try evaluating symbol again
1>

In an older DOS version of xlisp, I get the expected answer:
> (defun dof (f a b) (f a b))
DOF
> (dof #'+ 2 3)
5
>

I'm stumped.
Doug

From: David Betz
Subject: Re: Functions as arguments in xlisp
Date: 
Message-ID: <35326DD8.2693@xlisper.mv.com>
Doug Nelson wrote:
> 
> Can someone explain to me why the following does not work in xlisp 3.02?
> 
> > (defun dof (f a b) (f a b))
> dof
> > (dof #'+ 2 3)
> error: unbound function - f
> if continued: try evaluating symbol again
> 1>
> 
> In an older DOS version of xlisp, I get the expected answer:
> > (defun dof (f a b) (f a b))
> DOF
> > (dof #'+ 2 3)
> 5
> >
> 
> I'm stumped.
> Doug

It must have been a *very* old DOS version of xlisp. The problem is that
there is a different namespace for functions and variables. To call a
function passed in as an argument you need to use funcall:

(defun dof (f a b) (funcall f a b))

-- 
David Betz
·····@xlisper.mv.com
From: Erik Naggum
Subject: Re: Functions as arguments in xlisp
Date: 
Message-ID: <3101494170443846@naggum.no>
* Doug Nelson
| Can someone explain to me why the following does not work in xlisp 3.02?

  I'll take a wild guess.

| > (defun dof (f a b) (f a b))
| dof
| > (dof #'+ 2 3)
| error: unbound function - f
| if continued: try evaluating symbol again
| 1>

  (defun dof (f a b) (funcall f a b)) should work.  I guess xlisp 3.02
  adheres to the standard Lisp way of not evaluating the functional
  position in a form.

| In an older DOS version of xlisp, I get the expected answer:

  this is the standard Scheme way, and I think you could only expect that
  answer if you were thinking in Scheme terms.

#:Erik
-- 
  religious cult update in light of new scientific discoveries:
  "when we cannot go to the comet, the comet must come to us."