ERROR: syntax: malformed expression
whereas using a different variable name doesn't give an error
julia> x = 1; 2x+1
3
There must be some aspect of Julia syntax I have missed??
Thanks for any light you can shed on this...
Cheers,
Ron Rivest
julia> 2p+
(type-error double number #f)
unexpected error: #0 (read-number #<io stream> #f #f)
ERROR: syntax: malformed expression
9.154845485377136
That is, the spaces around the "+" are significant here, as to whether "e" is treated as the math constant or the floating point exponent notation...
I fear that "numeric literal coefficients" may introduce more hazards than its economy of notation justifies... ??
Cheers,
Ron
I fear that "numeric literal coefficients" may introduce more hazards than its economy of notation justifies... ??
On Julia version 3.4, the variable "P" also yields the same kind of error.
julia> 3e+130.0julia> 3e + 19.154845485377136
Perhaps this is a good reason to change behaviour such that e is no longer a constant: it has always seemed bit odd to use a valuable latin singleton in this way. We could use a unicode script e (U+212F) instead, as suggested by wikipedia:s
I think that using Unicode (outside ASCII) for numeric literals would be
more trouble than it is worth (typing, visually distinguishing them from
other similar-looking characters, etc). I feel that even if a language
supports Unicode, it should be usable with ASCII only.
I would prefer if Julia abandonned the abbreviated multiplication syntax
altogether: it looked very nifty when I first saw it, but it seems to be
a source of problems. I think that expressions with errors are only the
tip of the iceberg, I consider bugs that go unnoticed more noxious.
Usually a language handles this problem by making the constants such as p and e as reserved. Thus you can't create a new variable with those names and since they are constant you can't assign to them without raising an error.
> We might be able to find a more scalable syntax for different types of
numbers. For example the syntax x@000 is available; `@ then digit` is
always a syntax error currently.
2e+1 is 2x10^12e + 1 is 2*e + 12e+ 1 is a syntax error because to the lexical analyzer 2e+ is an error without at least 1 trailing digit (no spaces)
julia> 2e-1e
0.5436563656918091
Hex float literals are a different story. It's an understatement to
say they are VERY rarely used, and that most programmers don't need
them and have never heard of them. They also don't currently work
under MSVC (issue #6349). We have not had them very long. I say we
remove them. They can be replaced with a custom string literal.
julia> [1 + 2]1-element Array{Int64,1}:3julia> [1 +2]1x2 Array{Int64,2}:1 2