From: Stephan Houben <stephan@pcrm.win.tue.nl>
To: Pierpaolo BERNARDI <bernardp@cli.di.unipi.it>,
Pierre Weis <Pierre.Weis@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: Redefinition doesn't work
Date: Mon, 6 Nov 2000 10:29:22 +0100 [thread overview]
Message-ID: <00110610420100.30858@pcrm> (raw)
In-Reply-To: <Pine.LNX.4.10.10011031748000.1492-100000@comex13.cli.di.unipi.it>
On Fri, 03 Nov 2000, Pierpaolo BERNARDI wrote:
> For example, in Common Lisp it is forbidden to redefine system functions.
> In Scheme, you can define functions with the same name of a system one,
> but this redefinition cannot change the behaviour of other system
> functions.
And this is not very nice, since this forbids the "obvious" way to
implement various Scheme functions in terms of more primitive
ones. I.e. one would expect that Scheme implementations load
a preamble file which defines things like cadr as:
(define (cadr x) (car (cdr x)))
But this is incorrect, since redefining car would change the behavior of
cadr, which is explicitely forbidden. Correct way to do this:
(define cadr
(let ((my-car car)
(my-cdr cdr))
(lambda (x) (my-car (my-cdr)))))
Of course, even more problematic is that user code needs to do similar
hacks if it wants to be stable against redefinitions of standard procedures.
Moreover, it complicates compiler optimisation an awful lot (it becomes
basically impossible at the toplevel; it can be done in a batch compiler
where the whole source can be inspected to rule out (set! car ...) things).
> > I just tried to
> > compile my Scheme files as usual, calling some primitive function
> > named compile-file (or so), that unfortunately happened to use a
> > global function also named compile.
>
> This is not a property of Scheme, is a bug in the implementation you
> were using!
Since compile-file is not a R5RS standard procedure,
there is no guarantee that redefinition of *any* procedure might not change
the behavior of it. This makes use of any 3d party library in your Scheme
program very problematic, unless the Scheme implementation provides
a (non-standard) module system that fixes this madness.
Of course, I probably don't have to tell all this to the O'Caml developers,
who wisely chose *not* to follow Scheme in this regard...
Stephan
--
ir. Stephan H.M.J. Houben
tel. +31-40-2474358 / +31-40-2743497
e-mail: stephanh@win.tue.nl
next prev parent reply other threads:[~2000-11-06 22:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-02 22:45 Ruchira Datta
2000-11-03 9:13 ` Pierre Weis
2000-11-03 10:09 ` Michael Sperber [Mr. Preprocessor]
2000-11-03 16:56 ` Pierre Weis
2000-11-03 17:36 ` Michel Mauny
2000-11-05 11:15 ` Michael Sperber [Mr. Preprocessor]
2000-11-06 21:30 ` Bruce Hoult
2000-11-03 16:58 ` Pierpaolo BERNARDI
2000-11-06 9:29 ` Stephan Houben [this message]
2000-11-03 17:30 ` Stefan Monnier
2000-11-05 11:16 ` Michael Sperber [Mr. Preprocessor]
-- strict thread matches above, loose matches on Subject: below --
2000-10-31 19:11 Ruchira Datta
2000-11-02 18:05 ` Trevor Jim
[not found] <200010300739.IAA13016@pauillac.inria.fr>
2000-10-30 23:38 ` Jaeyoun Chung
2000-10-31 11:06 ` Pierre Weis
2000-10-31 11:52 ` Sven LUTHER
2000-10-31 16:47 ` Pierre Weis
2000-10-31 18:55 ` Stefan Monnier
2000-11-02 15:42 ` Pierre Weis
2000-11-03 3:10 ` Stefan Monnier
2000-10-31 14:16 ` Frank Atanassow
2000-10-31 17:07 ` Pierre Weis
2000-10-28 7:32 Mattias Waldau
2000-10-28 16:37 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00110610420100.30858@pcrm \
--to=stephan@pcrm.win.tue.nl \
--cc=Pierre.Weis@inria.fr \
--cc=bernardp@cli.di.unipi.it \
--cc=caml-list@inria.fr \
--cc=stephanh@win.tue.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox