[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question with binding
[...]
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...).
What is the difference between variables holding standard procedures
and those holding user procedures or those holding other kinds of
values (ie. pi, true, etc)?
There are two different issues here:
- The first is whether "system/language definitions" should be more
binding than user definitions. I certainly think that they should
not. The system is just a set of tools/utilities for the user, who
should be free to ignore them/replace them or do anything s/he wants.
For example, I may not like a system's definition of LENGTH, because
it is not generic accross lists, vectors ans strings. I should be
able to go ahead and redefine it. Since my new definition works on
lists as well, no one should notice except myself, who will be
considerably happier.
- The second issue is whether there should be immutable bindings, and
again I don't believe in them either. Say that you have written a
program which creates and maintains a database and that 10 years down
the road (during which it has been running continuously) you find a
bug in some utility. It would be nice to be able to replace it by a
correct version and continue as if nothing had happened. Not being
able to redefine it might waste 10 years worth of computation.
Nobody but yourself will change things underneath your feet, and you
can certainly impose any convention that you want on your variables,
but please don't build it into the language since I may consider your
conventions unreasonable.
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 are viewing it as an idle feature, which it is not. Consider it a
way that the system provides for installing patches and improvements.
As far as MacScheme is concerned, I'm not sure whether Will Clinger
still agrees to this or not, but I think that the last time we talked
about it he agreed that all bindings should be mutable, although
implementations might default to a "benchmark mode" in which some
bindings would be considered constant.
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?
Why should the system have precedence over me, the user? The system
should be just a library of utilities for me to use as I please.
More power to users, not to programs! :-)