guerrilla 7 days ago

(\ a#0 . a#0 a#0) (\ x#1 . \ y#2 . x#1 y#2)

-->

(\ x#3 . \ y#4 . x#3 y#4)(\ x#5 . \ y#6 . x#5 y#6)

1
SkiFire13 7 days ago

This implies that applying a function is no longer the same as a plain substitution. Moreover this can be pretty expensive computationally.

guerrilla 6 days ago

The semantics are the same for the user and debugging works, which is what matters. If you're using an object oriented language for implementation then this is already the computational cost. If you're using a functional language then yes there is some space overhead because it breaks sharing but that's the price. Was there something else you were thinking of?

SkiFire13 6 days ago

It's not just space overhead, it requires you to recursively walk the argument of the application and replace all variables with fresh ones, once for every occurrence of the function argument. This means that function application is no longer O(size of the function) but rather O(size of the function + occurrences of the argument * size of the argument). If the size of the argument is big this makes the function application much much slower.

wizzwizz4 5 days ago

It's not that expensive: just use De Bruijn notation under the hood. (I've seen a system that does this, and this is how it works.)

SkiFire13 3 days ago

But then the point of giving unique names to avoid using De Brujin indices is moot