The fix would be to suppress in-place assignment if the name is on the
stack in a higher-level sentence, and would not affect anything that
doesn't use in-place assignment.
Henry
On 6/21/2016 1:32 AM, 'Pascal Jasmin' via Source wrote:
At first I thought this was 3. normal behaviour
the assignment to ip is independent of the return value (which happens to be
ip) or the argument value.
The issue here though is that (ipm'') gets evaluated prior to ip, which is
surprising. also happens with:
((ipm '') ] ]) ip
2 1 2
but good news:
ip =: i. 3
(] [ ipm ) ip
0 1 2
ip
2 1 2
(ipm ] ]) ip
0 1 2
also behaves normally. while these don't.
(ipm ] ip"_ ) ''
2 1 2
(ip [ ipm ) ''
2 1 2
The workaround to get either behaviour is easy. In my first example I think
the parentheses gets executed before the right tine.
fixing it could be dangerous... could mess with:
inl=:(cocurrent@] ".@] [)"1 0
----- Original Message -----
From: Henry Rich <henryhr...@gmail.com>
To: Source forum <sou...@jsoftware.com>
Sent: Monday, June 20, 2016 10:45 PM
Subject: [Jsource] Language committee: in-place assignment rules
The issue:
ipm =: 3 : 0
ip =: 2 (0}) ip
)
ip =: i. 3
(ipm '') ] ip
2 1 2
As you see, ip was modified by call to ipm, which did an in-place
assignment. This violates the rules, which say that the value of ip
should have been stacked. In fact, a pointer to the value is stacked.
This requires a decision. I think we need a committee of J Language
Experts to decide how to resolve issues like this, and future enhancements.
The choices as I see them are:
1 - Fix to conform to the Dictionary. Possible; would slow things down
a little; would make some assignments currently done in-place perform a
copy.
2 - Ignore it. Leave as is.
3 - Embrace it - declare that in-place assignments to global variables
may affect previously-stacked references to the same name. [With local
variables the problem does not arise]
Now we need a Language Committee, and a decision.
Henry
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm