Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #40517

Re: local variable

From Bernd Linsel <bl1@gmx.com>
Newsgroups comp.lang.forth
Subject Re: local variable
Date 2015-07-11 11:03 +0200
Organization news.netcologne.de
Message-ID <mnqm48$vpt$1@newsreader4.netcologne.de> (permalink)
References (14 earlier) <830fadec-a923-4d6e-8125-4a4a274258ac@googlegroups.com> <b46d0efe-b8ac-4bfa-8246-a6459e5ebb76@googlegroups.com> <mnof8f$tst$1@dont-email.me> <ebe5f448-5311-4949-83c8-e420c71e7080@googlegroups.com> <mnoo9j$1ck$1@dont-email.me>

Show all headers | View raw


Am 10.07.2015 um 17:29 schrieb Alex McDonald:
 > on 10/07/2015 15:13:06, Raimond Dragomir wrote:
 >
 > [...]
 >
 > What is a static language or a dynamic language? They are terms I'm
 > unfamiliar with, unless you mean static vs dynamic typing, which is not
 > what we're taking about here. The discussion is about quotations in
 > relation to name scope and closure-like behaviour.
 >

"Static" and "dynamic" language references visibility/accessibility 
(scope) of symbols and lifetime (extent) of [local] variables.

Static (better: lexical) scoping means, you can derive the visibility of 
a symbol by examining the hierarchy in the source. The symbol is 
accessible within the block (function) it is defined in, and all the 
block's lexical children (functions in functions, local classes, 
quotations), but not its siblings or parent. This is standard in all 
newer languages that base on ALGOL. It can easily be implemented using 
stack frames.

With dynamic scoping, not the source code, but the runtime call chain 
determines visibility of symbols independently of their lexical 
relation. A called function may access variables defined in the calling 
function, even if they are defined in different locations.
Symbol accesses in such languages normally involve a symbol lookup at 
runtime, if the name can not be statically resolved at compile time -- 
which is the case for all non-locally defined symbols.

The extent describes when during the program's execution a variable's 
binding is retained. ALGOL-like languages have commonly *static extent*, 
meaning that their variables contents are lost when they go out of scope 
(the execution reaches their defining block's end). There are sometimes 
alternatives, e.g. C's "static" variables (with static scope and 
*infinite extent*), that have to be initialized when being defined and 
retain their bindings until termination of the program. Anytime the 
variable comes into scope (by execution of its containing block), you 
can access it (scope), and get the last assigned value (extent). The 
initialization is performed only once, at the first invocation.
Dynamic extent is still beyond this concept. With dynamic extent, 
variables exist in "activation records" or "environments", which, once 
created, persist as long as they could possibly be accessed, thus 
requiring garbage collection if one wants to reclaim this memory. A 
function with a living activation record becomes a closure, effectively 
holding a state between calls to that function. Lips's lambda functions 
and JavaScript's constructor functions are such closures.

I hope that makes the concepts and terms clearer.
Regards,
Bernd

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: local variable hughaguilar96@gmail.com - 2015-07-04 19:52 -0700
  Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 07:24 +0100
    Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 02:04 -0700
      Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 10:36 +0100
        Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 03:25 -0700
          Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 15:28 +0200
            Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:11 -0700
              Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:21 -0700
                Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 23:53 +0200
                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 20:31 -0700
            Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:56 -0700
        Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:57 -0700
          Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-06 08:09 +0100
            Re: local variable hughaguilar96@gmail.com - 2015-07-06 19:59 -0700
              Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-07 08:30 +0100
                Re: local variable Michael Barry <barrym95838@yahoo.com> - 2015-07-10 00:35 -0700
                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 01:41 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:55 +0100
                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 07:13 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 16:29 +0100
                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 08:57 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 17:48 +0100
                Re: local variable Paul Rubin <no.email@nospam.invalid> - 2015-07-10 10:02 -0700
                Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-09-16 17:30 +0000
                Re: local variable Mark Wills <markwills1970@gmail.com> - 2015-07-10 10:28 -0700
                Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 08:00 -1000
                Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:31 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 19:13 +0100
                Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 09:06 -1000
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 14:10 +0000
                Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-11 10:14 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:56 +0000
                Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-12 11:48 -0700
                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 21:21 -0700
                Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:56 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-11 23:51 +0100
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 13:42 +0000
                Re: local variable franck.bensusan@gmail.com - 2015-07-12 02:17 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:12 +0000
                Re: local variable franck.bensusan@gmail.com - 2015-07-13 02:37 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-13 16:13 +0000
                Re: local variable franck.bensusan@gmail.com - 2015-07-13 14:48 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-14 06:41 +0000
                Re: local variable franck.bensusan@gmail.com - 2015-07-14 01:44 -0700
                Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:03 +0200
                Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:11 +0200
                Re: local variable hughaguilar96@gmail.com - 2015-07-12 16:43 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 15:14 +0000
                Re: local variable Julian Fondren <julian.fondren@gmail.com> - 2015-07-11 17:57 -0700
                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:32 +0000
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:13 +0100
                Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:48 -0700
      Re: local variable franck.bensusan@gmail.com - 2015-07-05 03:47 -0700
        Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:15 -0700
          Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:27 -0700
            Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:39 -0700
          Re: local variable franck.bensusan@gmail.com - 2015-07-05 07:08 -0700

csiph-web