Names are reference-counted so that if you say a=:b=: 123 the reference
counts for a and b are each one more than if you'd said a=:123 and b=:123.
Before the interpreter modifies an array it checks the reference count and
if that count is not the minimum it will make a copy of the array before
modifying it.

> (but what would be the prupose?)

Shorter code.   a=:b=:c=: blah  is a common construct, in many programming
languages.



On Wed, Nov 23, 2011 at 6:16 AM, Ben Gorte - LR <[email protected]>wrote:

>
> Dear J forum,
>
> To my surprise I found out that
>
>    a =. b =. 480 640$0
>
> is not the same as
>
>    a =.  480 640$0
>    b =.  480 640$0
>
> as the first gives you two names pointing to the same data. I guess that
> should be ok, and it saves space (but what would be the prupose?)
>
> I passed both as pointers to a DLL (a .so in linux), which was supposed to
> put two different images in a and b, and then the first is not ok. It only
> works with the second variant :-)
>
> Greetings from Cape Town,
> Ben
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to