The issue: It looks like a field variable in a class behaves differently wrt hashing than a simple variable (not declared via :field).
Assume I have a private variable and a simple variable, each of which has been tagged as a hash (via ibeam 1500). If I use ,← to concat 1 or more values (here, char vectors), the hash status of the private variable is reset to 0, while the hash status of the simple variable remains 1 or 2 as expected.
Why is the behavior different?
Here's the class:
Code: Select all
:class test
⎕IO←0
:Field Private Peter← ⍕¨⍳10
:Field Private Paul← ⍕¨⍳10
Mary← ⍕¨⍳10
∇ make
:Implements constructor
:Access Public
hash
∇
∇ check
:Access Public
'Peter',1( 1500⌶) Peter
'Paul ',1( 1500⌶) Paul
'Mary ',1( 1500⌶) Mary
∇
∇ access
:Access Public
_← Peter Paul Mary⍳¨⊂1 3 ¯5
check
∇
∇ augment n
:Access Public
Peter,← ⍕¨10+⍳n
Paul,← ⍕¨10+⍳n
Mary,← ⍕¨10+⍳n
access
∇
∇ hash
:Access Public
Peter← 1500⌶Peter
Mary← 1500⌶Mary
'Peter and Mary (re)hashed. Paul not hashed.'
check
∇
:endclass
Code: Select all
a←⎕NEW test
Peter and Mary (re)hashed. Paul not hashed (feel free to ignore).
Peter 1 ⍝ hashing turned on
Paul 0 ⍝ for reference only: no hashing turned on
Mary 1 ⍝ hashing turned on
a.access ⍝ search each object
Peter 2 ⍝ 2 as expected
Paul 0
Mary 2 ⍝ 2 as expected
a.augment 1 ⍝ Append a char vector to each object via ,←
Peter 0
Paul 0
Mary 2
a.access
Peter 0 ⍝ Expected to be 1 (woe is me)
Paul 0
Mary 2 ⍝ Expected to be 2 (yay)