If you look at the compiled code, they seems to be equal *a = test(1,1.)*
julia> @code_native test2(a) .section __TEXT,__text,regular,pure_instructions Filename: none Source line: 2 push RBP mov RBP, RSP Source line: 2 vcvtsi2sd XMM0, XMM0, QWORD PTR [RDI + 8] vaddsd XMM0, XMM0, QWORD PTR [RDI + 16] pop RBP ret julia> @code_native test1(a) .section __TEXT,__text,regular,pure_instructions Filename: none Source line: 4 push RBP mov RBP, RSP Source line: 4 vcvtsi2sd XMM0, XMM0, QWORD PTR [RDI + 8] vaddsd XMM0, XMM0, QWORD PTR [RDI + 16] pop RBP ret Not sure how complex things get before they become different. kl. 14:21:24 UTC+2 onsdag 6. august 2014 skrev Tomas Krehlik følgende: > > In many cases I have chunks of code that take up too much space and worsen > readability of code in Julia. For example, I have some object on input, > which has many parameters and their particular combination is often used in > subsequent code. (In particular, I have an object containing Vector > Autoregression, which has number of observations and lags, etc. and those > are often combined in specifications of degrees of freedom, etc.) Is there > some macro, which would allow me to specify some "variables" without > allocating memory to those variables. I have in mind something like this: > > type test > a::Int64 > b::Float64 > function test(c::Int64, d::Float64) > new(c, d) > end > end > > function test1(ok::test) > a = ok.a > b = ok.b > return a + b > end > > function test2(ok::test) > return ok.a + ok.b > end > where I would like some macro to make test1 equal to test2. > >
