Looks super useful, thanks.

It looks like you let your example get out of date, here is a corrected 
version
using Delegate
import Base: <, <=, +, *, - # later I get WARNING: module Main should 
explicitly import < from Base if I don't import Base:

immutable AnInt
  val::Int
end
int1 = AnInt(1)
int2 = AnInt(2)

@delegate_1field2vars AnInt val [ (<), (<=) ]; # returns <=
@traject_1field2vars  AnInt val [ (+), (-), (*) ]; # returns *

int1+int2 # returns AnInt(3)
int1<int2 # returns true

# dont use the following, wrong number of arguments
#@delegate_1field2vars AnInt.val [ (<), (<=) ];



On Wednesday, June 15, 2016 at 4:18:50 AM UTC-6, Jeffrey Sarnoff wrote:
>
> Pkg.clone("https://github.com/Jeffrey-Sarnoff/Delegate.jl";)
>
>  
>
>> using Delegate 
>
> import <, <=, +, *
>
> immutable AnInt
>
>     val::Int 
>
> end 
>
>  
>
> int1 = AnInt(1) 
>
> int2 = AnInt(2) 
>
>  
>
> @delegate_1field2vars AnInt.val [ (<), (<=) ];           # plain results
>
> @traject_1field2vars( MyInt, val, [ (+), (-), (*) ] );   # type 
>> re-wrapped results
>
>  
>
> int1 < int2
>
> true 
>
>  
>
> int1 + int2
>
> AnInt(3) 
>
>  
>
>
> Also exports 2field versions and 1var versions.
> More examples are available in the README.md and in the tests.
>
> This is built on the work of John Myles White and Toivo Hennigsson.
>
>

Reply via email to