Talk:First class environments: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 9:
::::: A variable is a direct reference to data (the name of a memory location), while a dictionary is a data structure, which in turn has named elements. These are different concepts. A variable "phone" might point to a dictionary, and a key "alice" might be used to specify a location in the dictionary's memory area, but that's rather a "sub-variable". An expression "phone['alice']" is still an access to the original variable "phone", just with an offset or some lookup mechanism. "phone" is known by the program code directly, because it is in the program's environment. If that environment is implemented in the language as a kind of implicit dictionary, it is OK, just that for this task the environment (the association between "phone" and the contents of the corresponding memory location) must be manipulated as a first class datatype.--[[User:Abu|Abu]] 13:15, 1 July 2011 (UTC)
:::::: Ok, certainly: a dictionary is a collection of named references, and is not a single reference. Also: an entry in the dictionary was what I would think of as filling the same role as a variable -- I was not trying to suggest that the dictionary as a whole would fill the role of a single variable. So... this would make the dictionary key equivalent to a variable name for this task and a dictionary value equivalent to a variable value for this task? But I'm still not clear what this task adds to existing tasks (for example, considering the "Collections" task). --[[User:Rdm|Rdm]] 19:35, 1 July 2011 (UTC)
::::::: It is not about data structures like dictionaries or collections in general, but about how to use such structures to change the program's variable bindings. --[[User:Abu|Abu]] 12:51, 2 July 2011 (UTC)
::::::: Perhaps the concept of first class environments is foreign to many people because most programming languages don't support them natively. I'm not sure, but one reason may be that they don't fit well into statically compiled languages. For Python, they should be trivial to implement with dictionaries.
::::::: If first class environments are a true language feature, they give additional control to the programmer, over closures, continuations and other constructs. Not a big thing, but useful. For example, the PicoLisp GUI uses them to pass state between HTML pages and forms/dialogs across HTTP transfers. --[[User:Abu|Abu]] 09:32, 2 July 2011 (UTC)
Anonymous user