Introduction to the Theory of Programming Languages by Gilles Dowek & Jean-Jacques Lévy

Introduction to the Theory of Programming Languages by Gilles Dowek & Jean-Jacques Lévy

Author:Gilles Dowek & Jean-Jacques Lévy
Language: eng
Format: epub
Publisher: Springer London, London


4.3.4 Using de Bruijn Indices

To simplify the machine we can use De Bruijn indices—see Sect. 3.3. Recall that the instruction Searchx is generated by the compilation of variables, and we have already seen that it is possible to determine the index of each variable occurrence statically. We could then compile a variable x using the instruction Searchn, where n is a number, instead of earchx.

De Bruijn indices can be computed at the same time as the compilation is performed, it suffices to compile a term in a variable environment, and compile the variable x in the environment e by the instruction Searchn, where n is the position of the variable x in the environment e, starting by the end.

This mechanism allows us to dispose of variables in environments, closures, and instructions Mkclos and Extend. Our abstract machine includes the instructions Ldin, Push, Extend, Searchn, Pushenv, Popenv, Mkclosi, Apply, Test(i,j), Add, Sub, Mult and Div.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.