[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [r6rs-discuss] [Scheme-reports] redefining eqv?

On Wed, 2010-12-22 at 15:15 -0500, John Cowan wrote:

> I haven't found any Schemes except Scheme 9 on which this fails, but
> there is nothing in any Scheme standard to make it work.  In C, on the
> other hand, the equivalent construction is not allowed to fail: fopen()
> is naturally definable in terms of open(), but if you define your own open(),
> it cannot affect the behavior of fopen() on conformant ISO C systems.

That's because the definition of open() (typically a macro) is captured
when an unnamed library containing fopen() is compiled (for performance
reasons). And it is typically a direct interrupt to the OS. On the other
hand, with fopen() itself, you can play LD_PRELOAD tricks, hijack other
functions from that same library, or play linker tricks or ...

> On the gripping hand, if you define your own length in terms of cdr
> (as is natural), you will get a failure if cdr is redefined later in the
> The problem's a mess.

Can we do anything about it in the interpreter besides special-casing
a whole bunch of functions from the base library?

And should we do anything about it? Not that there are no other ways of
shooting yourself in the foot (see above)...

r6rs-discuss mailing list