Talk:First class environments: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 6:
::::: A dictionary encapsulates keys and values (must be explicitly accessed/fetched), but not variables and their values (transparently changing the behavior of the code).--[[User:Abu|Abu]] 06:00, 1 July 2011 (UTC)
::: No, nothing to do with objects. Objects encapsulate code and data. Environments encapsulate variables and their values (closures minus code).--[[User:Abu|Abu]] 06:00, 1 July 2011 (UTC)
:::: Ok, I give up. I have implemented the task (J implementation). The natural way of implementing it used objects. If I have failed to satisfy any of the task requirements, please let me know which requirements I have failed to satisfy. --[[User:Rdm|Rdm]] 13:07, 2 July 2011 (UTC)
:::: What are variables other than references to data and/or code? And, if it's that variables have mutable names (which would not actually be the case in many compiled languages), how is a variable name any different from a dictionary key? Using different words does not make the concept different -- you have to spell out the differences or illustrate them with examples. --[[User:Rdm|Rdm]] 10:54, 1 July 2011 (UTC)
::::: 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)
6,962

edits