Subject: Re: Functional programming
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1999/11/10
Newsgroups: comp.lang.lisp
Message-ID: <80atnu$5dcdo@fido.engr.sgi.com>
Tim Bradshaw  <tfb@tfeb.org> wrote:
+---------------
| * Tord Kallqvist Romstad wrote:
| > I cannot think of any situations in which this is useful.  Could you 
| > please give an example?  Thanks in advance!
| 
| I have code that looks like:
| 	(funcall (if multiprocessing-p #'process-run-function #'funcall)
| 	         #'(lambda ()
| 		     ...))
+---------------

But since in Scheme the "function" position is evaluated with the *same*
rules as the "arg" positions -- that is, the function position can be
*any* expression that evaluates to a function -- you can accomplish the
above in Scheme with:

  	((if multiprocessing-p process-run-function (lambda (x) (x)))
  	         (lambda ()
  		     ...))


-Rob

p.s. A definition of "funcall" that would work with the above *and*
handle the more general uses of "funcall" is:

	(define (funcall f . rest) (apply f rest))

Then you could say:

  	((if multiprocessing-p process-run-function funcall)
  	         (lambda ()
  		     ...))

-----
Rob Warnock, 8L-846		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		FAX: 650-933-0511
Mountain View, CA  94043	PP-ASEL-IA