As Henry indicates, changing the definition of "goo" so that "poo" gets run
before "r" is requested, e.g.

goo=: 3 : 0
   poo=. 3 :'r=:''value of r ='';y+1999' NB. r is global;poo is local
   aa=. poo 1
   (100+y);r;aa
)

solves the problem.  Still, it seems rather odd to invoke a local function
to set a global variable.


On 2/24/08, Henry Rich <[EMAIL PROTECTED]> wrote:
>
> The problem is, in
>
>
> (100+y);r;poo 1
>
>
> r is interpreted before poo is executed.  See the parsing
> table.  If r were a conjunction, poo might turn out to be dyadic,
> so r must be inspected before poo can run.  When it is interpreted,
> undefined r is assumed to be a verb, so you get a weird pun
> when later it turns out to be a noun.
>
>
> Henry Rich
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of david alis
> > Sent: Sunday, February 24, 2008 5:29 AM
> > To: Programming forum
> > Subject: [Jprogramming] global assignment in local explicit verbs
> >
> > Has this come up before.
> > In the example below an explicit verb itself contains the definition
> > of explicit verb, but assigned to a local name.
> > This local explicit verb sets the value of a global variable.
> > The container verb references this global variable.
> > The container verb throws a value error on the first invocation - but
> > not on the second and subsequent invocations.
> >
> > Is this a  bug - or perhaps it is documented somewhere...
> > (behaves same in previous version)
> >
> > NB. contents '1.ijs'
> >
> > invocation=:0
> > 4!:55<'r'
> > foo=: 3 : 0
> > 2(1!:2)~ 'invocation=';invocation=:>:invocation
> > goo 2
> > )
> >
> > goo=: 3 : 0
> > poo=. 3 :'r=:''value of r ='';y+1999'  NB. r is global;poo is local
> > (100+y);r;poo 1
> > )
> >
> > NB------------------------------------------------------------
> > -----------
> >
> >    load 'C:\Documents and Settings\david\j602-user\temp\1.ijs'
> >    foo 3
> > +-----------+-+
> > |invocation=|1|
> > +-----------+-+
> > |domain error: goo
> > |   (100+y);r    ;poo 1
> >
> >
> > NB. variable has been assigned within verb poo
> >    r
> > +------------+----+
> > |value of r =|2000|
> > +------------+----+
> >
> >
> >
> >    foo 3
> > +-----------+-+
> > |invocation=|2|
> > +-----------+-+
> > +---+-------------------+------------+----+
> > |102|+------------+----+|value of r =|2000|
> > |   ||value of r =|2000||            |    |
> > |   |+------------+----+|            |    |
> > +---+-------------------+------------+----+
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to