Some lua tricks you may not have known...
#81
Posted 29 June 2013 - 04:27 AM
#82
Posted 02 July 2013 - 04:49 AM
#83
Posted 19 July 2013 - 07:35 AM
#84
Posted 30 July 2013 - 10:37 AM
#85
Posted 31 July 2013 - 09:03 PM
#86
Posted 09 August 2013 - 04:40 AM
#87
Posted 27 August 2013 - 10:36 PM
#88
Posted 29 August 2013 - 06:58 PM
#89
Posted 03 September 2013 - 03:28 AM
[=[ can have --[[comments]] in it ]=]I just found this out
#90
Posted 20 November 2013 - 10:47 AM
#91
Posted 24 November 2013 - 11:14 AM
thanks a lot!!!
#92
Posted 24 November 2013 - 02:34 PM
Also, it'd be great if someone could inform me on how to have Lua syntax highlighting on here.
Edited by Kingdaro, 24 November 2013 - 02:34 PM.
#93
Posted 04 December 2013 - 10:42 PM
I think you use ```lua to get a Lua syntax highlight. Confirming now, will edit when confirmed.
Edit: Yep, you use ```lua , like this:
```lua print("Lua syntax highlighting!!!") -- Better lua code then that ```Some GitHub Tricks You Probably Knew />/>
EDIT: The editor derped up my post
Edited by awsmazinggenius, 04 December 2013 - 10:48 PM.
#95
Posted 05 December 2013 - 01:46 AM
distantcam, on 04 December 2013 - 11:23 PM, said:
EDIT: Sorry I should expand on that a bit.
LuaJ maintains 3 immutable arrays for a single table.
- an array to store indexed values
- an array to store hash keys
- an array to store hash values
It is also slightly slower to add a key/value pair as opposed to an indexed value due to the fact that there are two arrays that need to be modified; hashKey and hashValue arrays. Otherwise it is still fairly expensive to add elements to a table due to the fact that they must create a new array each time, since arrays in Java are immutable. I do think that they really should implement it as mutable data structures, for example an ArrayList and HashMap.
Edited by theoriginalbit, 05 December 2013 - 02:00 AM.
#96
Posted 05 December 2013 - 03:32 AM
Why is
table["foo"]slower than
table.foo?
#97
Posted 05 December 2013 - 04:51 AM
The latter function checks to see if what you put in the square brackets was a number or not, then if not, it just calls the former function and returns whatever that returns. Obviously it's faster to skip that extra check and call by rigging things so the former function is called directly.
It also appears that adding elements to a table does not require a new array each time - rather, if the current array is full then a new array double the size of the last is built, meaning after each resize it takes longer and longer until the next one is needed.
#98
Posted 17 May 2015 - 04:37 PM
distantcam, on 05 December 2013 - 03:32 AM, said:
Why is
table["foo"]slower than
table.foo?
This is also actually a thing in the Lua VM. It's because there's an entire opcode dedicated to accessing tables using dots.
An excerpt from http://lua-users.org...ationCodingTips;
Edited by digpoe, 17 May 2015 - 04:39 PM.
#99
Posted 18 May 2015 - 05:53 PM
digpoe, on 17 May 2015 - 04:37 PM, said:
An excerpt from http://lua-users.org...ationCodingTips;
*ahem, necro*
GET/SETDOTTED aren't present in Lua 5.1. They were in Lua 4. If there really is a difference, it probably would be from the Lua compiler emitting code which loads the string into a register before doing GET/SETTABLE rather than just referencing a constant index in the GET/SETTABLE instruction.
a.b = 3 settable <register of var a> <const index to string "b"> <const index to number 3> a["b"] = 3 loadk <some register r> <const index to string "b"> settable <register of var a> <r> <const index to number 3>
The register argument probably triggers the check for correct type like BombBloke was saying. The constant argument doesn't require this since it is guaranteed to be whatever its type is in the constant pool. Even if that's not the case, loading the constant into a register takes an extra instruction anyways.
#100
Posted 26 May 2015 - 07:22 PM
GitHub's current page system requires you to create a new project then create a branch named "gh-pages"-- I recommend setting this as the default branch-- , and finally then add an "index.html" file.
The squid knows all....
Edited by Thefdjurt, 27 May 2015 - 05:11 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users