You are right, and this is a blunder by me. The default should (and will) be 2. Put

9!:53 :: 0: 2

in your startup to see how it's supposed to work.

Henry Rich

On 10/4/2016 11:04 AM, 'Pascal Jasmin' via Beta wrote:
I think the default is 9!:53 ] 0, btw in this beta

notinplace =: 1 : '(9!:53@:2: ] u [ 9!:53@:0:) :: (] [ 9!:53@:2:)'

9!:53 ] 2

a  =: 1 2 3

a =: ('b' ,~ 3 ,~ ]) a

|domain error
|   a=:    ('b',~3,~])a
a
1 2 3 3


a =: 'b' ([ ,~ 4 ,~ ]) notinplace a  NB. no error displayed
a
1 2 3 3

a =: 'b' ([ ,~ 4 ,~ ])  a
|domain error
|   a=:'b'    ([,~4,~])a
a
1 2 3 3


(unchanged) as is the following

a=: (,&'b')@:(4,~])a
|domain error
| a=: (,&'b')@:(4,~])a
a


a=:    ('b' ,~ 4,~])a =: 1 2 3  NB. also "fails"
a=:    ('b' ,~ 4,~]) 'a'~ [ a =: 1 2 3


in last expressions, was expecting an extra 4 appended.  Does dyad 
automagically break the inplace behaviour?

an alternate version of notinplace (to display error) is:


notinplace =: 1 : '(9!:53@:2: ] u [ 9!:53@:0:) :: (assert@:0: [ 9!:53@:2:)'


but I think there needs a new 13! foreign that is simply "reraise last error"


In terms of comments on the bugs = off switch,

I'm ok with it.  This would be done primarily in explicit code.

Even though new optimizations strongly favour reusing variables when no longer 
needed.  Fortunately this doesn't happen


v =: 3 : '4 ,~ y'
a =: ('b' ,~ v) a
|domain error
|   a=:    ('b',~v)a
a



So I suspect that the behaviour is pretty safe in that within an external verb, 
an error will indicate where to fix the code without changing external y, and 
so fix and rerun will not cause problems.

The simplest approach to avoid problems for code that may raise an error is to 
assign compound result to new variable

If you are making in place assignments interactively in console, odds are you 
are testing expression prior to adding assignment step, and if not, you likely 
have original assignment still in input log.

I think its important to consider the future inplace improvements (dyad, v@:, 
multi same assignments on one line).  For instance, this would be a way to get 
inplace benefits, while being sure that rerunning the line will produce the 
same result regardless of error.


a=: ('b' ,~ 4,~])a =: 1 2 3


We could also set policy that this will never be optimized, and so make this 
safe from possible confusion:

a=: ('b' ,~ 4,~])'a'~

Basically, a one time possible break (even if super rare) of code is far 
preferable to an issue that may break with every future optimization.
----------------------------------------------------------------------
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