The DataFramesMeta packages has an @with macro that does something similar:
https://github.com/JuliaStats/DataFramesMeta.jl/ It currently works for Associative types and AbstractDataFrames (object lookups based on getindex). One difference is that you refer to fields using symbols, so :bar + :baz in your example. You could use that as a starting point for a macro that works with Composite types. The @with in DataFramesMeta could probably be extended to work with Composite types. In @with, the use of getindex would have to be abstracted out, so field lookup can be used instead. On Tue, Feb 10, 2015 at 9:45 AM, Tamas Papp <[email protected]> wrote: > Hi, > > Is there a macro in Julia similar to CL's WITH-SLOTS? Eg > > type Foo > bar > baz > end > > function foo(f::Foo) > @with_fields f (bar,baz) > bar+baz > end > end > > would be the same as > > function foo(f::Foo) > f.bar + f.baz > end > > If not, then some hints on how to write this would be welcome. I could > not find anything equivalent to symbol macros in Julia, which are used > to implement this in CL. > > Best, > > Tamas >
