to get the package, clone this git://github.com/JuliaArbTypes/DelegationMacros.jl.git <https://github.com/JuliaArbTypes/DelegationMacros.jl>
On Tuesday, September 6, 2016 at 6:14:22 PM UTC-4, Jeffrey Sarnoff wrote: > > This offers updated macros to assist with delegating into/through fields > of a defined type. > > Two macros apply a function to field value(s) yielding the functional > result; > and two others do that and then rewrap the result in the source type. > > The exports are: > @delegate_oneField, > @delegate_oneField_fromTwoVars, > @delegate_oneField_asType, > @delegate_oneField_fromTwoVars_asType > > They work so: > > import Base:string, show, (<), (<=), abs, (-), (+), (*) > > immutable MyInt16 > value::Int16 > end > > three = MyInt16(3) > seven = MyInt16(7) > > > @delegate_oneField( MyInt16, value, [string, show]) > > string(three) == "3" # true > show(seven) # 7 > > > @delegate_oneField_fromTwoVars( MyInt16, value, [ (<), (<=) ] ) > > three < seven # true > seven <= seven # true > > > @delegate_oneField_asType( MyInt16, value, [abs, (-)]) > > abs(three) == three # true > -seven == MyInt16(-7) # true > > > @delegate_oneField_fromTwoVars_asType( MyInt16, value, [ (+), (*) ] ) > > three + seven == MyInt16(3+7) # true > three * seven == MyInt16(3*7) # true > > > > > >
