chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] inlining + identity of literals


From: Thomas Chust
Subject: Re: [Chicken-hackers] inlining + identity of literals
Date: Thu, 8 Apr 2010 11:12:36 +0200

2010/4/8 felix <address@hidden>:
> [...]
> Something that I'm not sure how to handle: should
> literal quoted data keep its identity when the containing
> code is copied due to inlining? Or should the data be
> copied as well (the latter is the current behaviour).
> [...]

Hello Felix,

I consider it extremely bad style to rely on the mutability of
literals, so I wouldn't mind if structurally equal literal constants
were folded, whether there is inlining involved or not.

However, if I would rely on the mutability of literals, I would still
intuitively expect that "the same" literals keep their identity
throughout the code, for example I would expect that every closure
generated by

  (define (make-foo)
    (let ([p '(0 . 1)])
      (lambda ()
        (set-car! p (+ 1 (car p)))
        (set-cdr! p (* 2 (cdr p)))
        (* (car p) (cdr p)))))

would always access the same object bound to p. This is precisely the
contrast I expect between a quoted literal and a freshly constructed
value.

In fact this is normally true in CHICKEN, but if inlining copies
literals, the property is violated and hence inlining can change the
behaviour of the code. In my opinion it would be ideal if compiler
optimizations like inlining made some efforts not to change the
behaviour of a program.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]