That does sound like a good thing to check with lint. Whether it should be considered a bug or not might depend on how the language spec is interpreted. The documentation <http://docs.julialang.org/en/release-0.3/manual/integers-and-floating-point-numbers/#man-numeric-literal-coefficients> says "Julia allows variables to be immediately preceded by a numeric literal," the only exceptions being explicit hexadecimals and literal floats (e.g. 0xff, 1e-10). I couldn't find anything explicit saying it's okay to write x.2 to mean x*0.2. If there's any code out there using that, I wonder if it's an undiscovered bug or really intentional.
On Wednesday, June 17, 2015 at 9:07:25 PM UTC-4, Patrick O'Leary wrote: > > Changing this would be breaking--syntax that currently works (even if you > don't expect it to) wouldn't work anymore. If someone is actually using > this syntax, then we'd break their code on a release which is billed as a > minor maintenance release. That's not going to work. > > There may be a Lint.jl check for this, though? It sounds familiar. > > On Wednesday, June 17, 2015 at 5:12:31 PM UTC-5, Art Kuo wrote: >> >> That's great that it's fixed in 0.4, but even in 0.3.X I would still >> label it inconsistent behavior, or perhaps even a bug. Why should this >> happen: >> >> *julia> **x.2 == x*.2* >> >> *true* >> >> *julia> **x0.2 == x*0.2* >> >> *ERROR: x0 not defined* >> >> *julia> **x2 == x*2* >> >> *ERROR: x2 not defined* >> >> It seems consistent that .2X == .2*X, 0.2X == 0.2*X, 2X == 2*X, so it is >> fine if the number occurs before the variable. But not if the number occurs >> after, so I agree with the proposal to ban X.2, meaning trigger an error. >> Shouldn't this be the case for 0.3 versions as well? >> >> >> On Wednesday, June 17, 2015 at 9:14:24 AM UTC-4, Seth wrote: >>> >>> >>> >>> On Wednesday, June 17, 2015 at 8:04:11 AM UTC-5, Jerry Xiong wrote: >>>> >>>> Today I spend many time to find a bug in my code. It is turn out that I >>>> mistakenly wrote sum(X,2) as sum(X.2). No any error information is >>>> reported >>>> and Julia regarded X.2 as X*0.2. The comma "," is quite close to dot "." >>>> in >>>> the keyboard and looks quite similar in some fonts. As there is no any >>>> error occur, this bug will be dangerous. Also, it is not intuitive to >>>> understand X.2 is X*0.2. I think maybe it is better to forbid syntax like >>>> X.2 but only allowed .2X. >>>> >>> >>> This appears to be fixed in 0.4: >>> >>> julia> x = 100 >>> 100 >>> >>> julia> x.2 >>> ERROR: syntax: extra token "0.2" after end of expression >>> >>> julia> sum(x.2) >>> ERROR: syntax: missing comma or ) in argument list >>> >>> julia> f(x) = x.2 >>> ERROR: syntax: extra token "0.2" after end of expression >>> >>> julia> f(x) = sum(x.2) >>> ERROR: syntax: missing comma or ) in argument list >>> >>> >>> >>
