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

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



On Sun, Jun 2, 2013 at 7:48 PM, Peter Bex <Peter.Bex@x> wrote:
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.

Yes, this argument was brought up before and already
discredited.  Procedure inlining is still a perfectly valid
optimization, whether or not the procedure is a primitive.

The R6RS semantics allows for optimizations in exactly
the opposite cases, when the compiler is unable to inline
the procedure.  The exact cases it is applicable is
when the procedure is referenced conditionally at least
twice but usually not at all.  See earlier explanations by
myself and John Boyle for details.

There are also other less interesting optimizations which
could be applied given the R6RS semantics, such as
(eqv? expr1 expr2) => (begin expr1 expr2 #f) when either of
expr1 or expr2 can be type-inferenced to a procedure.

-- 
Alex

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