Translating this Python code
    
    
    a = [1, 2, 3]
    b = a
    b.append(4)
    print(a) # [1, 2, 3, 4]
    
    
    Run

to Nim requires quite some manual dereferencing:
    
    
    var a = new seq[int]
    a[].add [1,2,3]
    var b = a
    b[].add(4)
    echo a[] # @[1, 2, 3, 4]
    
    
    Run

which can be avoided by using the [experimantal 
pragma](https://nim-lang.org/docs/manual_experimental.html#automatic-dereferencing)
    
    
    {.experimental: "implicitDeref".}
    
    var a = new seq[int]
    a.add [1,2,3]
    var b = a
    b.add(4)
    echo a # @[1, 2, 3, 4]
    
    
    Run

I wonder why automatic dereferencing for the first proc argument is not the 
standard, whereas [implicit 
dereferencing](https://nim-lang.org/docs/manual.html#types-reference-and-pointer-types)
 of ref object fields is performed.

Further after seeing this recent [pull 
request](https://github.com/nim-lang/Nim/pull/19379/commits) without any 
discussion in the conversation tab I'm a bit unsure about using this IMO nice 
feature.

Reply via email to