-
February 18th, 2020, 17:59 #1
- Join Date
- May 2018
- Posts
- 56
Naming conventions for data types?
Is there a post or style guide that shows the naming conventions for the data types in FG?
So far I gather the following:
a = array
b = [edit: boolean]
s = string
k = key
v = value
t = table
i = index
Not sure about:
n (number?)
r (resource?)
f (floating number?)
v (vector? when used as a prefix instead of by itself)
I might have missed some other prefixes.
Thanks!Last edited by k410; February 18th, 2020 at 19:01.
-
February 18th, 2020, 18:17 #2
b == boolean
r == recordtype (at least the scripter I asked thinks that's what it is)
-
February 18th, 2020, 18:24 #3
- Join Date
- May 2018
- Posts
- 56
Thanks, Talyn. I thought "boolean" and typed "binary". Not a good start!
r == recordtype makes sense, now that you mention it.Last edited by k410; February 18th, 2020 at 18:35.
-
February 18th, 2020, 19:28 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,557
It's all a bit ad hoc. I started adding those lower case letters in front to help people reading the code know what "type" variables are expected to be, since Lua is untyped.
Prefix
b = boolean
n = number (usually integer, but not always)
f = number (float)
s = string
a/t = table
v = variable (could be anything, or even different value types) (example: database path or database node reference)
r = "record" (basically a table with some sort of expected format)
Variable Names
k = arbitrary ipairs/pairs key
v = arbitrary ipairs/pairs value
i/j = arbitrary number value
Regards,
JPG
-
February 18th, 2020, 19:32 #5
- Join Date
- May 2018
- Posts
- 56
Thanks, Moon Wizard!
(I'm finally motivated to learn Lua and am partway into the 2019 Lua Beginner's Guide from Lua Publishing.)Last edited by k410; February 18th, 2020 at 20:07.
-
February 25th, 2020, 17:04 #6
It a bad thing to toss up on the developer page, Moon. As you might recall, I asked the same thing long ago. If I’d seen this before now, I could have answered all except t (hadn’t seen), f (didn’t recall) and v (variable one, stand-alone I recall as part of k,v)
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks