1. #1

    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.

  2. #2

    Join Date
    May 2016
    Location
    Jacksonville, FL
    Posts
    1,846
    Blog Entries
    7
    b == boolean
    r == recordtype (at least the scripter I asked thinks that's what it is)

  3. #3
    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.

  4. #4
    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

  5. #5
    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.

  6. #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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in