lua-users home
lua-l archive

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


Hi, I was just wondering out of curiousity, if there were an overhead involved in using the multiple assignment, purely out of style (terse source code) as opposed to semantic reasons.

That is, I know multiple assignment is semantically needed here:

    -- swap values
    x, y = y, x

Presumably, extra work is needed to ensure the proper semantics. I'm wondering if a statement like this:

    x, y = math.pi/2, math.pi/4

which doesn't need the extra work, would be less efficient than this:

    x = math.pi/2
    y = math.pi/4

Or, if there would be other reasons to prefer one style over the other. I suppose disassembly would be informative, but I'm interested in insight and commentary the experts might have. Oh and I'm mostly interested in 5.1 now, but eyeing 5.2, and if it's different in 5.0 I'd find that interesting too.