English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: Redefinition doesn't work
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-11-03 (15:37)
From: sperber@i...
Subject: Re: Redefinition doesn't work
>>>>> "Pierre" == Pierre Weis <Pierre.Weis@inria.fr> writes:

>> Stefan Monnier wrote:
>> >>>>>> "Pierre" == Pierre Weis <Pierre.Weis@inria.fr> writes:
>> >> It is not only a question of type. As I mentioned in my previous
>> >> message, if you allow the user to ``rebind'' some basic functions,
>> >> such as map or iter, the behaviour of the compiler can be
>> >> unpredictable.
>> >
>> >It never seems to bother Lisp users.
>> It must have bothered some Lisp users, otherwise why does Scheme have
>> lexical scoping?
>> Ruchira Datta
>> datta@math.berkeley.edu

Pierre> Scheme has lexical scoping <EM>locally</EM>. It has dynamic binding
Pierre> globally,


Pierre> just to address this redefinition problem (as far as I can
Pierre> imagine a clever justification to this extremely strange behaviour). I
Pierre> remember my surprise when I was porting to Scheme some fancy
Pierre> metacompilation stuff written in Caml: unfortunately the Caml code
Pierre> ended by redefining (globally) the functions load and compile; how
Pierre> strange errors messages when the internals of the Scheme compiler
Pierre> tried to use those functions in place of its original versions! I
Pierre> needed a long time to figure out what was happening, since I did not
Pierre> use directly any Scheme function named compile: I just tried to
Pierre> compile my Scheme files as usual, calling some primitive function
Pierre> named compile-file (or so), that unfortunately happened to use a
Pierre> global function also named compile.

What you're describing is not a binding issue, but an assignment
issue.  (Look in R5RS, 5.2.1 for an explanation.)  Moreover, what
you're describing is (at least not in spirit) not conformant with
R5RS.  Section 6 has this:

  [Global binding alterations] do not modify the behavior of Scheme's
  built-in procedures.

Pierre> That's an example of a user that does not want the functions to be
Pierre> redefined everywhere, since he cannot understand the consequences of
Pierre> the redefinition since he does not even know where the rebound
Pierre> function was used!

Sounds like an implementation bug to me.

Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla