Re: tagged procedures vs procedure properties
Per Bothner 01 Sep 2021 01:57 UTC
On 8/31/21 6:19 PM, Shiro Kawai wrote:
> Mutable procedure property is a bit difficult to deal with.
>
> (define (foo)
> (lambda (x) x))
>
> (define f1 (foo))
> (define f2 (foo))
>
> (set-procedure-property! f1 'prop 1)
> (get-procedure-property! f2 'prop) => What this should be?
>
> If f1 and f2 always need to be distinct objects, it restricts optimization severely.
I understand the concern, but I'm not sure we'd actually be missing anything.
I think an intuitive semantics is that each evaluation of (lambda ...)
conceptually creates a district procedure value - just like (cons ...) does.
If a compiler can determine that no-one modifies a procedure (either though
set-procedure-property! *or* by modifying closed mutable values) *and* no-one
compares the procedures using eq? then a compiler can merge them to a single
value - just as it can for pairs created by cons.
What real optimization would be lost under this semantics - which I suspect
matches most real implementations?
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/