🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #92

Re: Static scoping in J.

#92
From: Raul Deluth Miller-Rockwell
Date: Tue, 07 Apr 1992 05:24
49 lines
2034 bytes
Theo Norvell wrote in response to one of my posts on the scope of J,
and tacitly encouraged me to post a response.  Below is his letter and
my response.

>  >Have I left any situation uncovered?

>  Hi.  The acid text for static scoping is usually something like
>  this: 

>          var A
>          A := 0

>          function whatIsA
>                  return A
>          end

>          function acidTest
>                  var A 
>                  A := 13
>                  return whatIsA
>          end

>          A := 7

>          acidTest  -- 7 gives static scoping, 13 gives dynamic scoping,
>                    -- and 0 is something a bit unusual.

>  How would this example look in J?  What would be the answer?

Well, one way of coding this in J might be
   A =: 0
   whatIsA  =:   'A' : ''
   acidTest =:   ('A =. 13'; 'whatIsA 0') : ''
   A =: 7

then, when I execute
   acidTest 0
I get 7.

One side issue worth noting is that J requires that all functions take
an argument.  For pathological cases, like the above, where the
argument is not necessary, you still need to supply a dummy argument
to meet the syntactic requirements.  

By the way, an analogy to this syntactic rule is chemical bonding --
it is when chemicals join that energy is released.

-- 
Raul Deluth Miller-Rockwell                   <rockwell@socrates.umd.edu>
Technical Details
Message-ID: <ROCKWELL.92Apr7002438@socrates.umd.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!socrates!socrates!rockwell
References: <1992Mar15.221628.24491@yrloc.ipsa.reuter.COM> <ks8boqINN8ht@network.ucsd.edu> <ROCKWELL.92Mar31185022@socrates.umd.edu> <1992Apr3.172844.6152@newshost.lanl.gov> <ROCKWELL.92Apr4080945@socrates.umd.edu> <STEPHEN.92Apr4215253@estragon.uchicago.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!socrates!socrates!rockwell
From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Subject: Re: Static scoping in J.
Message-ID: <ROCKWELL.92Apr7002438@socrates.umd.edu>
Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell)
Organization: Traveller
References: <1992Mar15.221628.24491@yrloc.ipsa.reuter.COM> <ks8boqINN8ht@network.ucsd.edu> <ROCKWELL.92Mar31185022@socrates.umd.edu> <1992Apr3.172844.6152@newshost.lanl.gov> <ROCKWELL.92Apr4080945@socrates.umd.edu> <STEPHEN.92Apr4215253@estragon.uchicago.edu>
Date: Tue, 7 Apr 1992 05:24:38 GMT