JavaScript trick: `===` can be used to detect two object "a" and "b" if there 
are pointed to the same object. An object in JavaScript is kind like `ref 
object` in nim and every data mutation directly to `a` can be accessed from `b` 
when they are `===` equal. It's much faster to just compare `a === b` to know 
they are identical than comparing every properties.

Suppose in Nim, I have a type:
    
    
    type A = ref object
      x: int
    
    let a = A(x: 1)
    
    let b = a
    
    echo a == b
    
    echo a.unsafeAddr.repr
    echo b.unsafeAddr.repr
    
    
    Run

when it compares with `==`, it compares values and returns `true`. But their 
pointers are different:
    
    
    true
    ptr 0x10fbabc28 --> ref 0x10fbd1048 --> [x = 1]
    
    ptr 0x10fbabc30 --> ref 0x10fbd1048 --> [x = 1]
    
    
    
    Run

Since we learnt the trick of JavaScript, and noticed that both `a` and `b` 
refers to the ref `ref 0x10fbd1048`. Can I skip value comparing and just figure 
out that they are the same ref?

Reply via email to