Bill,

I get your point, but if the results are available (as shown by the use of the 
values by c =: 0 + b ....  what could the optimisation be.  I mean what would 
be the increase in speed or decrease in memory when there already is a data 
block that the "0 + " uses to produce the result for c.

Leaving that aside, I'm still pleasantly surprised at the extent of the 
optimisation which shows up in the analysis. Though I would have thought that 
u^:n (where n = 0) was an additional place where the data block pointers would 
have been just copied, as apparently is the case
for  ]^: n (where (_1 = n) +. (1 = n +/ . >: 1 _))   

Ian

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of bill lam
Sent: Tuesday, 17 May 2011 3:25 PM
To: [email protected]
Subject: Re: [Jgeneral] Incorrect results in j701 - and doing nothing

I guess this is not lazy evaluation, but a problem of reference, in the
sentences b=: a or b=: a;c
there is no value-copying at this point, only the reference count of 
data block of a or c increases and header of b points to that data. Normally
when a is updated eg, a=: a+1, then the tie between a and b will break. The
reported bug seems to be related to the inability to detect a has been
changed and the old data block is no long valid.

   a=: 2 ]/\ i.4
   smoutput a
0 0 7995393                
NB. a reference to the data block of i.4 which has been released

   a=: 2 ]/\ b=: i.4
   smoutput a
1 2 3
NB. no error since data block pointed by b is still valid

   b=: i.4   NB. change memory address of data block
   smoutput a
0 0 6356993
NB. same error
 
   a=: a:{ 2 ]/\ i.4
   smoutput a
1 2 3
NB. no error because a is copy-by-value using a:{

Втр, 17 Май 2011, Ian Shannon писал(а):
> Roger,
> 
> From the example below, it appears that the correct processing is being done, 
> it is just when assigning a name to the results that your special code runs 
> into trouble,  OR  the  J system is doing some lazy evaluation.
> "In certain cases, instead of explicitly doing }:y and }.y, the code 
> constructs headers which point to the same data, thereby saving time and 
> space."
> 
> Does J do lazy evaluation, that is delaying a calculation until needed with 
> the potential of not doing a calculation if the result is not used?
> 
> Playing around with 2 infix below has given me a bit more insight into J.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential 
and/or privileged information. 
If you are not the intended recipient, please notify the sender and then delete 
it immediately.
Any views expressed in this email are those of the individual sender except 
where the sender expressly and with authority states them to be the views of 
the Office of Environment and Heritage, NSW Department of Premier and Cabinet.

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to