[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [BUG] Table constructor not equivalent to left-to-right assignment (Was: Testing for a sequence ...)
- From: Rena <hyperhacker@...>
- Date: Sat, 21 Apr 2012 23:03:15 -0600
On Sat, Apr 21, 2012 at 11:58, Robert Virding
<robert.virding@erlang-solutions.com> wrote:
> I personally think that having things undefined, implementation specific, and still not illegal is a Bad Thing (tm). It is too easy to write something which works and then make a small innocuous change and suddenly it no longer works. Or worse, it "works" but produces the wrong answer which in the worst case you don't see is the wrong answer. Unfortunately those who are hit hardest are those with the least chance of understanding what is wrong and what to do about it: the inexperienced. Telling them that they shouldn't do that is not really helpful.
>
> No, it is worth converting undefined to error generating illegal.
>
> Robert
>
> ----- Original Message -----
>> On 21 April 2012 14:36, Petite Abeille <petite.abeille@gmail.com>
>> wrote:
>> >
>> > On Apr 20, 2012, at 9:20 AM, Dirk Laurie wrote:
>> >
>> >> I think you have discovered a bug. §3.4.8 of the manual states
>> >> clearly,
>> >> by way of an example, that a table constructor is equivalent to
>> >> assignment
>> >> of the entries from left to right.
>> >
>> > <joke>
>> > Patient: Doctor, doctor, it hurts when I do this.
>> > Doctor: So don't do that.
>> > </joke>
>> >
>> > Trivia 1: What's the value of 'a'?
>> >
>> > local a, a = 1, 2
>> >
>> > print( a )
>> >
>> Undefined, yet really implementation specific
>>
>> > Trivia 2: What's the value of 'a'?
>> >
>> > local a
>> >
>> > a, a = 1, 2
>> > print( a )
>> >
>> >
>> Undefined, yet really implementation specific
>>
>> Liam
>>
>>
>
Perhaps what you want is a linter or debugger that will warn you about
undefined operations like this during development. I personally
wouldn't care for the extra overhead in constantly checking these
things at runtime when I can just not rely on such behaviour, but
being warned would be useful when you're first writing the code.
--
Sent from my toaster.