Name: Anonymous 2011-10-27 13:16
So, reading the trying the LTU imperative/declarative papers made me think.
A function and a function call can seen as a renaming and environment building operation. Are there any other not-as-mainstream ways to perform the same thing?
A piece of code is executed in an environment where variables have meaning attached to them. How do those variables get a meaning?
[list][li]Locally introduced variables. Intermediate values are given a name, or perhaps a local function is defined, which needs to refer to local variables.[/li][li]Function parameters. A general piece of code is run for some arbitrary parameter values.[/li][li]A global name in C for instance - the program linker finds a function/value with the given name in some object file and places a reference to it where ever it's used.[/li][li]A closure is made which is able to refer to variables in the environment it was created in.[/li][li]A class defines an environment for a set of methods. The environment is passed as one parameter to the metods.[/li][li][tt]set[/tt] in lisp, which gives a new value to a symbol passed as a parameter.[/li][/list]In a way, all of the examples above are different ways of linking. Only one of them is performed at compile time, the others are done at run-time.
Are there other ways to extend/manipulate the environment found in programming languages? Can you think of any other way that is might not be feasible to implemenmt in a programming language?
A function and a function call can seen as a renaming and environment building operation. Are there any other not-as-mainstream ways to perform the same thing?
A piece of code is executed in an environment where variables have meaning attached to them. How do those variables get a meaning?
[list][li]Locally introduced variables. Intermediate values are given a name, or perhaps a local function is defined, which needs to refer to local variables.[/li][li]Function parameters. A general piece of code is run for some arbitrary parameter values.[/li][li]A global name in C for instance - the program linker finds a function/value with the given name in some object file and places a reference to it where ever it's used.[/li][li]A closure is made which is able to refer to variables in the environment it was created in.[/li][li]A class defines an environment for a set of methods. The environment is passed as one parameter to the metods.[/li][li][tt]set[/tt] in lisp, which gives a new value to a symbol passed as a parameter.[/li][/list]In a way, all of the examples above are different ways of linking. Only one of them is performed at compile time, the others are done at run-time.
Are there other ways to extend/manipulate the environment found in programming languages? Can you think of any other way that is might not be feasible to implemenmt in a programming language?