Everyone,
I am sure that there is a perfectly good reason for the parser to
allow a construct like:
for i in 17; println(i); end
But, I am unable to see how this can be useful/helpful since a loop
like this will only ever execute once. I have now had two bugs
stemming from this behaviour, for both cases `17` was replaced with a
function call. What I intended to write was something like the
following:
for i in 1:17; println(i); end
Thus, I thought it was a good idea to ask about this, according to me,
little peculiarity, so that I can determine whether I am introducing
bugs/rambling on due to my own ignorance, or if this is indeed
something that should be fixed. For those interested and familiar
with the Julia introspection, here is the dump of the expression:
julia> dump(:(for i in 17; println(i); end))
Expr
head: Symbol for
args: Array(Any,(2,))
1: Expr
head: Symbol =
args: Array(Any,(2,))
1: Symbol i
2: Int64 17
typ: Any
2: Expr
head: Symbol block
args: Array(Any,(2,))
1: LineNumberNode
line: Int64 1
2: Expr
head: Symbol call
args: Array(Any,(2,))
typ: Any
typ: Any
typ: Any
For reference, I am running a fairly recent master version of Julia
(master/8f1fbec*).
Pontus