If, for example, I were wanting to create a crazy new int type that stored its 
value as product of primes, and I was not concerned with performance, I could 
create my own pure nim type in a library.
    
    
    type
      intAP = object
        setOfPrimes: array[0..50, int]
    
    
    Run

... and, using operator overloading, it would mostly work just like any other 
int. I could add, subtract, etc. and it would all behave just like any other 
int.

I can even mix the types. I could even add a int64 and a intAP together and 
return either a new int64 or intAP (depending on how I wrote it.)

But the one thing I can't do is plain assignment.
    
    
    # works:
    
    var a: int = 5
    var b: int64 = 5
    var c: int16 = 5
    var d: float = 5
    
    # doesn't work:
    
    var e: intAP = 5
    
    # workaround:
    
    var e: intAP = createIntAP(5)
    
    
    Run

This isn't a deal breaker. But it would really be nice if the operator overload 
proc allowed for different target types.

Akin to:
    
    
    proc `=`(n: var intAP, target:intAP) =
       n.setOfPrimes = target.setOfPrimes
    
    proc `=`(n: var intAP, target:int) =
       # blah blah blah mathy stuff
    
    
    Run

Various places in the forum it has been hinted that this might one day be 
possible. So, two questions: Does this cause any fundamental problems? Is it on 
the roadmap?

Just curious.

Reply via email to