The version without @eval is better. You shouldn't use @eval if you don't have to; it should be faster without it.
-- Leah On Thu, May 8, 2014 at 2:42 PM, 'Stéphane Laurent' via julia-users < [email protected]> wrote: > Actually I'm rather using the followig function allowing to remove several > lines. > > function removeLines(poly::Poly, indices::BitArray{1}) > > for op = (:a, :b, :x1, :y1, :x2, :y2, :typ) > > @eval $poly.$op = ($poly.$op)[!$indices] > > end > > end > > > function removeLines2(poly::Poly, indices::BitArray{1}) > > for op = (:a, :b, :x1, :y1, :x2, :y2, :typ) > > poly.(op) = (poly.(op))[!indices] > > end > > end > > > Le jeudi 8 mai 2014 21:04:52 UTC+2, Stéphane Laurent a écrit : > >> Cool, thank you Jameson. >> >> So what is the best choice between these two possibilities : >> >> function removeLine(poly::Poly, index::Int) >> >> for op = (:a, :b, :x1, :y1, :x2, :y2, :typ) >> >> @eval splice!($poly.$op, $index) >> >> end >> >> end >> >> >> function removeLine2(poly::Poly, index::Int) >> >> for op = (:a, :b, :x1, :y1, :x2, :y2, :typ) >> >> splice!(getfield(poly, op), index) >> >> end >> >> end >> >>
