I'll apply your patch and see if it works. After reading it more carefully I think I understand your decrement count. Nice code! On Tue, Jan 14, 2020 at 5:36 PM Stefan Israelsson Tampe < stefan.itampe@gmail.com> wrote: > 1. I don't understand why you decrement the count in operator position > 2. I don't see that you increase the count when a procedure is returned > from a lambda > > Example > (define (f a) a) > (define (g) > (hash-set! H f 1) ; (*) > (f 1)) ;(**) > (define (h) > (pk (hash-ref H f))) ; (*) > > (g) > (h) > > => '(#f) as count in your patch is counted up twice (*) and down ones (**) > in total count = 1 so you will not maintain the identity of f and you will > get a bad printout > > Then we also have this example > (define (f a) a) > (define (u) f) > (define (g) (hash-set! H (u) 1)) > (define (h) (pk (hash-ref H f))) > > (g) > (h) > This will again print (#f) as the count will be 1. > > /Stefan > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Jan 14, 2020 at 5:16 PM Andy Wingo wrote: > >> On Tue 14 Jan 2020 15:47, Stefan Israelsson Tampe < >> stefan.itampe@gmail.com> writes: >> >> > Yes, your patch is indicating when you should use the same identity >> > e.g. all uses of procedures in a higher order position such as an >> > argument or a return value. But I looked at your patch, which looks >> > good but I saw that for operator position you decrease the count. Why? >> > Also you are free to use one version in argument / return position and >> > another one in operator position the only limit is to use the same >> > identity for on operator position. Finally don't you need to count >> > usage of returning a variable as well? >> >> Not sure what the bug is. Do you have a test case that shows the >> behavior that you think is not good? >> >> Andy >> >