Talk:Variable

I made some changes to the "Names of variables" section:

  • The section discussed many attributes that belonged in the identifier article. I've reworded and moved a few paragraphs (for example about naming conventions and Lisp symbols) for that reason.
  • I replaced the discussion of namespaces by a link to the namespace (computer science) article.
  • Changed the section name to "variable names".

-- Eelis 01:17, 2005 May 23 (UTC)



I think the text in the "Computer programming" section of this revision (http://en.wikipedia.org/w/wiki.phtml?title=Variable&oldid=4928052) is much more clear and readable than the current text. It is far from perfect but the current text has a lot of bad English and ambiguous sentences, and uses erratic terms, such as "life-time" in place of the standard term "extent". I think it is a better place to work from than the current text. I'd revert -- but I wrote much of the old text and am certainly biased. Anyone else watching? --FOo 05:30, 1 Aug 2004 (UTC)

It's been almost two weeks with no comment, so I'm restoring several paras of the older version, somewhat improved and better laid-out. --FOo 12:17, 10 Aug 2004 (UTC)
I think it is a matter of perference. I replaced the old text by a new one for the same reason the old text uses unheard term like extent instead of life-time and is rather unorgainzed and spending too much on somehow irrelevant topics like scoping. There is an article about scope so this article should not spend too much on it. Particularly, the article is making a wrong impression about storage. The key to understand variables is binding. Scopes merely help binding and unbinding process. GC, for instance, has nothing to do with variables. Objects that are not realized by any variable could exist and can be reclamied or not. I believe the new one is far clear on this matter. True, I have removed some parts in the old text so later I will try to merge them into one. -- Taku 03:07, Aug 21, 2004 (UTC)
While I respect your views, I do not believe they are representative of the field we are discussing. The terms scope and extent are in standard use in computer science. [1] (http://www.cs.man.ac.uk/~pjj/cs2111/ho/node14.html) [2] (http://www.dcs.warwick.ac.uk/~john/jade/jade_145.html) [3] (http://www.supelec.fr/docs/cltl/clm/node43.html) [4] (http://tinuviel.cs.wcu.edu/~shults/Spring2003/CS151/handouts/Scope.html) The term "lifetime" (not "life-time") is sometimes used as a synonym for "extent", but Google searches suggest it is less common.
You have eradicated several paragraphs of useful discussion of scope and extent, of typed and untyped variables, of function parameters, and storage of variables. While you may believe these are not relevant, they are most certainly related in computer science literature. Garbage collection, for instance, has substantial effects on the way programmers use variables.
I agree with you on the importance of the concept of binding. Please consider working this in to the larger, more complete text rather than deleting wholesale sections that I and others have written. I am restoring the deleted material in parallel with your text. I will be soliciting comment from others who have edited this article recently on how the two can be reconciled. --FOo 01:29, 27 Aug 2004 (UTC)

I have heard both terms lifetime and extent used for variables. I don't think one is particularly more clear than the other, but perhaps they both should be mentioned the first time. I may try to work on the phrasing there, but the english in that whole paragraph is a mess. ("life-time" is a mispelling IMHO.) Also, I think scope should be described in terms of binding, as scope and extent are only related for the special case of local variables, and are not related when refering to static variables, global variables, dynamic variables, class variables, etc... This paragraph is really just a disorganized jumble of concepts. The concepts of scope, lifetime, binding, gc'ing, etc., all need to be defined each in their own paragraph before you try to relate them and mix them together. I think it is very helpful, however, to include (limited) examples of languages that use each technique. The concept of Garbage collection (vs. malloc/free) is extremley important. C and assembly programmers will not survive until they understand these things and how they relate to the lifetime of a variable, which may exceed its scope or may be exceeded by its scope. (I.e., passing a reference to a variable that is about to die is a bug. Allowing a reference to go out of scope without freeing its target (and thus ending its lifetime) is a different bug.) Does extent apply to a length of (run)time, a length of code, or both? This needs to be clarified. --ssd 03:31, 27 Aug 2004 (UTC)

I think this quote from Guy L. Steele's Common Lisp: the Language describes the interplay between scope and extent well:
[T]he notions of scope and extent are frequently useful. These notions arise when some object or construct must be referred to from some distant part of a program. Scope refers to the spatial or textual region of the program within which references may occur. Extent refers to the interval of time during which references may occur. [5] (http://www.supelec.fr/docs/cltl/clm/node43.html)
In other words, scope is a lexical fact, but extent a runtime (dynamic) fact. I would go so far as to say that scope has to do with names, extent with bindings of variables to values, and memory allocation with values (or rather, data objects that represent values). If a name is out of scope, you can't even bind it; if it is out of extent, you can't refer to it except to bind it, which gives it a new extent; if its value is still taking up memory when it's out of extent, it's a leak (in C) or garbage (in Java or Lisp).
When a variable binding extends (in time) as the program's execution passes out of the variable's scope, this is no bug. It is a Lisp closure or a C static variable: when execution passes back into the variable's scope, the variable may be referred to again. But when a variable's extent ends, it becomes unbound -- if it is still in scope, referring to it is an error (or, in C, gets you a nice arbitrary value).
Extent is related to memory reclamation. When a variable becomes unbound, if its value is occupying storage it must be reclaimed. This is where memory allocation (be it manual or automatic) comes in. In a non-gc system like C, it is a memory leak bug when an object (a data representation of a value) continues to take up storage after no more variables are bound to it. In a gc system like Java or Lisp, it is no bug; the gc reclaims the storage. --FOo 04:57, 27 Aug 2004 (UTC)
Heh, now to incorporate that nice description into the article... --ssd 00:06, 29 Aug 2004 (UTC)

I think there needs to be a more clearly defined seperation between variables in CS and variables in mathematics - there is a quite distinct treatment of the two. Perhaps the section for CS can look something like Operator - cover a short paragraph or two on the important topics and leave the important treatment to the respective articles? Dysprosia 11:58, 31 Aug 2004 (UTC)


Hello. I wonder about the reference to Help:Variable in this article. I'm not in favor of self-references within WP but I can see that someone might easily come here looking for special wiki variables. Suggestions? Regards & happy editing, Wile E. Heresiarch 15:57, 25 Jan 2005 (UTC)

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools