Replace your macro with a function and delete the uses of eval. You code will be faster, and easier to understand. Most of the difficulty people seem to have with macros comes from thinking they are a type of function call -- the @ character is supposed to remind you that this is not true.
On Thursday, May 8, 2014, Johan Sigfrids <[email protected]> wrote: > I myself have been hitting my head against the wall that is > meta-programming in Julia. I think I can answer your first question at > least. > > Q1: This is because the line poly = emptyPoly doesn't create a new copy > of a ploygon but a reference to the empty one so that both poly and emptyPoly > refer to the same data. You need to do poly = deepcopy(emptyPoly) . > > On Thursday, May 8, 2014 9:56:27 AM UTC+3, Stéphane Laurent wrote: > > Hello everybody, > > Below I define two new types : Line and Poly. The Poly type is intended > for stacking some lines. > > type Line > > a::Float64 # intercept > > b::BigFloat # slope > > x1::BigFloat # x-coordinate of first vertex > > y1::BigFloat # y-coordinate of first vertex > > x2::BigFloat # x-coordinate of second vertex > > y2::BigFloat # y-coordinate of second vertex > > typ::Bool # type of the line (true:upper, false:lower) > > end > > > type Poly > > a::Vector{Float64} > > b::Vector{BigFloat} > > x1::Vector{BigFloat} > > y1::Vector{BigFloat} > > x2::Vector{BigFloat} > > y2::Vector{BigFloat} > > typ::Vector{Bool} > > end > > > > I also define the empty Poly: > > emptyPoly = Poly(Array(Float64,0), Array > >
