It's definitely a revisitable choice, but that consideration would have to
come along with some thought about how array indexing in general is
implemented – which is something that we're due for.

On Saturday, March 29, 2014, Tom Lee <m...@tomlee.id.au> wrote:

> Thanks for the heads up, maybe I'll just have to live with it and be more
> careful...
>
> On Saturday, 29 March 2014 11:04:56 UTC-4, Stefan Karpinski wrote:
>>
>> That's not a good idea – or at least it's bound to cause you some nasty
>> problems. There is a lot of indexing code in Base (and probably elsewhere
>> too) that depends in individual Ints being iterable like this. I'm not a
>> huge fan of it personally, but it seems be pretty handy when trying to
>> write generic multidimensional array code – the idea being that a scalar
>> behaves like a zero-dimensional tensor. In any case, it's not a thing that
>> can be changed by itself without also changing a lot of other code that
>> relies on the current behavior.
>>
>> On Mar 29, 2014, at 10:25 AM, Tom Lee <ma...@tomlee.id.au> wrote:
>>
>> I've only been using Julia a few weeks and typos of this sort must have
>> cost me several hours of debugging in total. You have given me an idea
>> though, I think I try to find the method in Base for iteration over an
>> integer and edit it myself to make it raise an error.
>>
>> Cheers,
>> Tom
>>
>> On Saturday, 29 March 2014 08:29:22 UTC-4, andrew cooke wrote:
>>>
>>>
>>> sorry, i wasn't clear.
>>>
>>> Base defines the methods necessary for it for iteration "over" an
>>> integer.
>>>
>>> julia> for i in 8
>>>        print(i)
>>>        end
>>> 8
>>>
>>> i am suggesting this is not a good idea.
>>>
>>> andrew
>>>
>>>
>>>
>>> On Saturday, 29 March 2014 00:42:35 UTC-3, Leah Hanson wrote:
>>>>
>>>> You can make any type iterable (by defining start, next, and done); you
>>>> could, if you wanted, make Int/Integer/whatever iterable. Making an Int
>>>> literal a syntax error here would create inconsistent behavior when someone
>>>> (inevitably) decides to iterate over Ints for some reason.
>>>>
>>>> I assume you got a NoMethod error about start?
>>>>
>>>> -- Leah
>>>>
>>>>
>>>> On Fri, Mar 28, 2014 at 8:19 PM, andrew cooke <and...@acooke.org>wrote:
>>>>
>>>>>
>>>>> maybe there's a good reason for this (i suspect there is, but i'm not
>>>>> seeing it right now).  but if there isn't, removing it might save some 
>>>>> poor
>>>>> typist or confused newbie from a frustrated debugging session.
>>>>>
>>>>> the problem is that
>>>>>
>>>>> for i in 8
>>>>>     ...
>>>>> end
>>>>>
>>>>> isn't a syntax error (when what was meant was the range 1:8)
>>>>>
>>>>> cheers,
>>>>> andrew
>>>>>
>>>>
>>>>

Reply via email to