I don't think this is a parser issue. It would be strange to not allow 
integers specifically in a context where we accept anything else.

The problem is how integers are defined as iterable in 
base/number.jl#L36-l39 
<https://github.com/JuliaLang/julia/blob/master/base/number.jl#L36-l39>, 
I'm sure I read some discussion about this behaviour somewhere, but I can't 
find it. I think the argument for them was that it would be somewhat 
friendly to Matlab users.

Ivar





kl. 09:28:01 UTC+2 onsdag 18. juni 2014 skrev Pontus Stenetorp følgende:
>
> 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 
>

Reply via email to