Subject: Re: Separate namespaces [was: Re: please tell me the design faults]
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 7 Mar 2001 03:59:21 GMT
Newsgroups: comp.lang.lisp
Message-ID: <984bmp$1ag21$1@fido.engr.sgi.com>
Bruce Hoult  <bruce@hoult.org> wrote:
+---------------
| Erik Naggum <erik@naggum.net> wrote:
| > Scheme works very, very hard to not to distinguish a function call from
| > any other variable reference.  And vice versa.  At least give them 
| > credit for having achieved that, even though it is a fundamentally
| > silly thing to want to do.
| 
| How is that? If you see something at the start of a non-quoted list 
| then you know it must be a reference to a function (or possibly, an error).
+---------------

I think what Erik might be referring to is that Scheme insists that the
evaluator use *THE EXACT SAME* evaluation rules on the function position
as on the argument positions. That is, the evaluator basically does this:

	(let ((evaled-args (mapcar #'eval exp)))
	  (funcall apply (car evaled-args) (cdr evaled-args)))

[Except the "mapcar" is *not* required to execute left-to-right or
right-to-left or any other fixed order -- only *some* serializable order.]

That lets Scheme get away with writing stuff like this, where the function
position can be an arbitrary expression:

	> (define x 13)
	> ((if (odd? x) + *) 2 3)
	5
	> 

instead of as in CL:

	> (defvar x 13)
	X
	> (funcall (if (oddp x) #'+ #'*) 2 3)
	5
	> 

[In CL, of course, the Scheme style is an error: ]

	> ((if (oddp x) #'+ #'*) 2 3)

	*** - EVAL: (IF (ODDP X) #'+ #'*) is not a function name
	1. Break> 

Now do Scheme programmers ever *use* that generality? Actually, very
seldom. I've used it maybe a couple of times, total, in several years of
Scheme hacking. I probably wouldn't even miss it much if it were gone.
(You'd still have "apply", and you can trivially define "funcall" in
terms of "apply".)


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
SGI Network Engineering		<URL:http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA