Talk:First class environments: Difference between revisions

no edit summary
m (mistyped closure as clojure)
No edit summary
Line 8:
:::: 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)
:::::: 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)
Concerning the question whether the C solution "fits the spirit": I would say yes, though instead of switching the pointers to 'sec' and 'cnt' I would save and restore the actual values. This would better simulate the "binding" of the "environments".--[[User:Abu|Abu]] 15:17, 30 June 2011 (UTC)
: Well, that's quite a bit more work. Right now I can just swap the links (addresses) and forget about it (which is in a sense more "real"), if I copy values, I'd have to copy them back after each job switch, can't exit job control loop whenever I want, etc. The way I look at it, just pretend the "*" is a special marker for environment variables. In the worst case, the job function itself can copy and restore them to stack if really needed. --[[User:Ledrug|Ledrug]] 16:40, 30 June 2011 (UTC)
6,951

edits