To expand upon the unicode operator thing:

It's a "do-it-yourself" kind of deal. You get to define the meaning of these 
operators, and they syntactically work like the pre-defined `+`, `-`, etc.

e.g.
    
    
    func `∪`[T](a, b: set[T]): set[T] =
      return a + b
    
    func `∪=`[T](a: var set[T]; b: set[T]) =
      a = a + b
    
    echo {'a', 'b'} ∪ {'c', 'd'}
    var x = {'e', 'f'}
    x ∪= {'g', 'h'}
    echo x
    
    
    Run

This will define a union operator with the symbol `∪`, and also a shortcut for 
`a = a ∪ b` as `a ∪= b`. (Of course, you could also define it to do whatever 
else, but that sounds evil :P)

In contrast, the above syntax does not work with a regular function name:
    
    
    func union[T](a, b: set[T]): set[T] =
      return a + b
    
    func `union=`[T](a: var set[T]; b: set[T]) =
      a = a + b
    
    # echo {'a', 'b'} union {'c', 'd'} # won't compile
    echo {'a', 'b'}.union {'c', 'd'} # you'd have to do this instead.
    var x = {'e', 'f'}
    # x union= {'g', 'h'} # this doesn't work either
    x.union = {'g', 'h'} # this does, but is very confusing in this context...
    echo x
    
    
    Run

(Of course, the above dance is entirely redundant for sets, you can just use 
`+` to the same effect.)

So in short, nothing that you can't do _without_ unicode; if you find the 
unicode version clearer, or feel compelled to turn Nim into APL, then Nim gives 
you the tools you need.

(In fact, I have never felt the need to use unicode operators. I'm also 
convinced that anything other than ASCII does not belong in program source 
code, but I know many people disagree.) 

Reply via email to