[julia-users] Re: Help with a macro

2016-06-21 Thread Mosè Giordano
Hi Kristoffer, 2016-06-21 22:19 GMT+02:00 Kristoffer Carlsson: > > Using @eval in a macro is generally the wrong thing to do. A macro should > simply transform an expression to another expression. Ok, that's probably what I'm missing, thank you! > If you give an example function body and wh

[julia-users] Re: Help with a macro

2016-06-21 Thread Kristoffer Carlsson
On Tuesday, June 21, 2016 at 4:35:09 PM UTC-4, Mosè Giordano wrote: > > Hi Kristoffer, > > 2016-06-21 22:19 GMT+02:00 Kristoffer Carlsson: >> >> Using @eval in a macro is generally the wrong thing to do. A macro should >> simply transform an expression to another expression. > > > Ok, that's pr

[julia-users] Re: Help with a macro

2016-06-21 Thread Mosè Giordano
2016-06-21 23:02 GMT+02:00 Kristoffer Carlsson: > > > Your macro should not evaluate anything per say. It should generate > expressions that when the code is run will call functions. > > Say a user types @uncertain log(x,y), what do you want the resulting > expression after macro expansion has r

[julia-users] Re: Help with a macro

2016-06-22 Thread Mosè Giordano
Ok, here is a simpler example, not specific to Measuments.jl. From @foo f(x, y, z, ...) get f([x.re, y.re, z.re, ...].^2 + [x.im, y.im, z.im, ...]) The expression provided to the macro should can take any number of arguments. For example: x = complex(3.2, -5.2) y = complex(8.9, 0.4) @foo(lo

[julia-users] Re: help with a macro

2016-01-18 Thread Jeffrey Sarnoff
If you revise the macro as Stefan suggests, would you post the revision as a response here? On Thursday, January 14, 2016 at 8:09:23 AM UTC-5, richard@maths.ox.ac.uk wrote: > > This macro: > > macro clenshaw(x, c...) > bk1,bk2 = :(zero(t)),:(zero(t)) > N = length(c) > for k = N:-

Re: [julia-users] Re: Help with a macro

2016-06-22 Thread Mauro
A REPL session of mine trying to figure out how to make that macro would look something like this: julia> ex = :(f(x, y, z, zz)) # this is what is passed into the macro :(f(x,y,z,zz)) julia> xdump(ex) # xdump is nice to get an overview of nested datastructures Expr head: Symbol call args: Ar

Re: [julia-users] Re: Help with a macro

2016-06-23 Thread Mosè Giordano
Hi Mauro, 2016-06-22 21:13 GMT+02:00 Mauro: > > A REPL session of mine trying to figure out how to make that macro would > look something like this: > > julia> ex = :(f(x, y, z, zz)) # this is what is passed into the macro > :(f(x,y,z,zz)) > > julia> xdump(ex) # xdump is nice to get an overvi