[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question with binding
Date: 17 Apr 89 20:36:41 GMT
From: titan!dorai@rice.edu (Dorai Sitaram)
Subject: Re: Question with binding
Message-Id: <3107@kalliope.rice.edu>
In article <8904171910.AA26688@polya.Stanford.EDU> shap@POLYA.STANFORD.EDU (Jonathan S. Shapiro) writes:
>I have been thinking about compiling scheme, and am confused about the
>following possibility:
>
> (define foo (lambda (x) (+ x 2)))
> (define + (lambda (x y) something))
> (foo)
>
>If this is legal, I don't understand how a compiler can validly inline
>primitives. Is there some provision in R3RS or R4RS that resolves
>this problem, or is it really a problem? If the latter, how do
>compilers deal with it?
>
>Jon
[...]
A bunch of primitive functions, e.g., +, cons, etc., were treated as
_constants_ in the sense that the names could not have other values
assigned to them. [...]
^^That's my understanding too: the idea that certain procedures can't change
during the course of a compilation/computation, otherwise things couldn't be
guaranteed to make sense if they were meanwhile allowed to change underneath
your feet during the computation/compilation. As to user defined
functions--well if you want to do those sorts of things with your own functions,
okay, but the system won't let you do that with its functions (upon which it
might depend, or otherwise feels some responsibility to protect the integrity
of). Something like that...(and I too profusely apologize if I misstated or
oversimply stated...).
In MacScheme, if you try (define + ...) you get:
ERROR: Integrable procedures may not be redefined.
(set! + ...)
I like the idea of that a great deal...I don't think the convenience of being
able to redefine things (advertently or inadvertently--with or without warning)
is a wonderful feature. You can always write your own similar functions with
different names, and call out to those in preference if a system function isn't
quite what you wanted, right?
--dorai