|
| 02 Jul 2013 11:28 PM |
I'm a better coder than all of you, but I request some assistance on something that most of you are incompetent to do. For some reason, running a,a=1,5 leaves a holding a value of 1. Why is this? I'd assume it's a simple explanation if any of you are able to comprehend a question of mine, so go ahead and tell me. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2013 11:29 PM |
Whoops, forgot to enable siggy after calling C&G dumb
~1waffle1 |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 02 Jul 2013 11:30 PM |
| I'm just going to stop now. :/ |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2013 11:31 PM |
Hurry up, you slow morons.
~1waffle1 |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 02 Jul 2013 11:33 PM |
| Number one, Waffle doesn't talk to people like that. |
|
|
| Report Abuse |
|
|
|
| 02 Jul 2013 11:34 PM |
| It's a joke over exaggerating the superfluity of 1waffle1's personality. I don't expect ANYONE to believe it's him - he's much more respectful than this. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 02 Jul 2013 11:36 PM |
| As for the variable issue, I have no clue! I suppose it relates to it trying to set an entry in the environment twice at the same moment, and the first takes an override... |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 02 Jul 2013 11:40 PM |
It is not an exaggeration of my personality, it is an exaggerated misinterpretation of my personality directed towards the wrong people. As for the problem;
t={} setmetatable(t,{__newindex=function(a,b,c)print(c)end}) t[1],t[1],t[1]=1,2,3
|
|
|
| Report Abuse |
|
|
LuaWeaver
|
  |
| Joined: 28 Jun 2013 |
| Total Posts: 213 |
|
|
| 02 Jul 2013 11:40 PM |
Using ChunkSpy interactive mode:
>a,a=1,5 ; source chunk: (interactive mode) ; x86 standard (32-bit, little endian, doubles)
; function [0] definition (level 1) ; 0 upvalues, 0 params, 2 stacks .function 0 0 2 2 .const "a" ; 0 .const 1 ; 1 .const 5 ; 2 [1] loadk 0 1 ; 1 [2] loadk 1 2 ; 5 [3] setglobal 1 0 ; a [4] setglobal 0 0 ; a [5] return 0 1 ; end of function
They seem to get compiled in opposite order. |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2013 12:29 AM |
@LuaWeaver: >They seem to get compiled in opposite order.
This is because Lua allocates registers like a stack. Last in, first out. The actual expressions are compiled in the order you would expect, first push 1 and then 5 onto the stack, but then the actual destinations are compiled in reverse as the values 5 and 1 are popped off of the stack. |
|
|
| Report Abuse |
|
|
LuaWeaver
|
  |
| Joined: 28 Jun 2013 |
| Total Posts: 213 |
|
|
| 03 Jul 2013 01:11 AM |
@NecroBumpist
I figured that out. I've been reading "A No-Frills Introduction to the Lua VM". Great read.
while obamacare() do benefitMiddleClass() end --LuaWeaver |
|
|
| Report Abuse |
|
|
|
| 03 Jul 2013 01:23 AM |
@LuaWeaver: A very informative read indeed. I wonder how long it took to research and put the entire paper together. Anyway, keep up your work with Lua bytecode :3 It's very interesting. |
|
|
| Report Abuse |
|
|
LuaWeaver
|
  |
| Joined: 28 Jun 2013 |
| Total Posts: 213 |
|
|
| 03 Jul 2013 03:55 AM |
@NecroBumpist: I wrote my own bytecode schema. ;)
\3\1\1\15\2\0\0\1\10\2\0
Is the same as:
tiny int arg0=15; add arg0,10 out top of stack
while obamacare() do benefitMiddleClass() end --LuaWeaver |
|
|
| Report Abuse |
|
|