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

Re: [Scheme-reports] Procedural equivalence: the last debate



On Sun, Jun 02, 2013 at 12:03:38AM -0400, John Cowan wrote:
> For example, it is possible for an implementation to rewrite calls on `car`,
> which is stateless, into calls on `%internal-car`, which the compiler knows
> how to inline.  All references to `car` in operand position are then
> rewritten as `(lambda (pair) (%internal-car pair))`.  Consequently,
> `(eqv? car car)` will naturally return `#f`, since two lambdas are now
> involved where in the source there was only one.

I've never understood this jump in logic: If the compiler only rewrites
car in operand position, how would you ever be able to obtain a reference
to it?  All other cars are not rewritten, so (eq? car car) will always
refer to the non-rewritten version of car.

Even if the compiler is able to deduce that a procedure application of
some stored object really refers to CAR, it only needs to rewrite the
actual application.  For uses of comparison it can still refer to the
non-optimized car.

Besides, a compiler is not supposed to make optimizations which change
the semantics of the language (unless the user explicitly asks it to
break these semantics).  This means that the above is not bogus:
using the "real" car everywhere except for applications is fine, as long
as it has no observable effect on the program's behaviour (besides being
faster, of course).

Cheers,
Peter
-- 
http://www.more-magic.net

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports