MikeInnes / Lazy.jl

I was gonna maintain this package, but then I got high
Other
470 stars 54 forks source link

Incorrect result using @>, +, - #44

Open rogerwhitney opened 8 years ago

rogerwhitney commented 8 years ago

New to Julia and just found this library. Is there something obvious that I am missing to explain the following (other than macros can be tricky to get right)? Perhaps this is related to issue 40?. I have

@> [1 2; 3 4] +([1 1;1 1]) *([1,2])
returning [9, 21]. It is not clear how to get that result. @> [1 2; 3 4] +([1 1;1 1]) returns the correct result. The following returns [8, 14]

@> [1 2; 3 4] begin +([1 1;1 1]) *([1,2]) end

The expression fails: @> [1 2] +([1 1]) *([1,2]). @as has similar problems. I expected that the two expression below should return the same results. The first one fails.

@as x [1 2;3 4] +(x, [1 1;1 1]) (x, [1,2]) @as x [1 2;3 4] x + [1 1;1 1] x \ [1,2]

TotalVerb commented 8 years ago

Careful with using operators as functions. You should often surround them with parentheses. Try:

@> [1 2; 3 4] (+)([1 1; 1 1]) (*)([1, 2])

I don't think this is really a bug, as it would be bad for x +(y) to parse as x and then (+)(y) IMO.