lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I don't get it? How about, just don't do it? Why should anybody ever do that?

Altough its not as easy to shoot ones foot with modern high level languages, in almost all of them it is still possible to create code with ill-defined behavior.

( I welcome the collection of ill-defined ways to code for academic interests, its sometimes not too easy to find how to. But other than that, who cares? )

PS: Almost any language has ill-defined behavior by calling a sort with a custom comparator where for example a > b, b > c, c > a

On Mon, Sep 15, 2014 at 9:07 AM, Tom N Harris <telliamed@whoopdedo.org> wrote:
On Sunday, September 14, 2014 05:18:50 PM Coda Highland wrote:
> I can't imagine any way it wouldn't be a bug if you did do it, but a
> realistic way I could see such a thing arising unintentionally is
> like:
>
> tbl[a], tbl[b], tbl[c] = k1, k2, k3
>
> where a, b, and c are determined by some logic external to the
> function. If any of a, b, or c are the same value, you trigger this
> behavior.

Also relevant when __newindex is defined on the metatable and has side-
effects.

But I think you'd have to be some kind of sadist to put side-effects in a
metatable function. Nothing obfuscates a program more than when what looks
like a simple `=' sign means more than just assign a value to the lvalue.

--
tom <telliamed@whoopdedo.org>