[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Let's talk about order of assignment
- From: Sean Conner <sean@...>
- Date: Wed, 17 Sep 2014 15:34:39 -0400
It was thus said that the Great Tom N Harris once stated:
> 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.
I'm guilty of that. My POSIX process libary [1] allows:
process.limits.hard.core = "20m"
but behind the scenes it turns that into a call to setrlimit(). I find
"assigning" the values more intuitive than knowing how to call the
setrlimit() function. Conversely, reading process.limits.hard.core in turn
calls getrlimit().
-spc
[1] https://github.com/spc476/lua-conmanorg/blob/master/src/process.c
starting around line 637