-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repr improvement #6597
base: develop
Are you sure you want to change the base?
Repr improvement #6597
Conversation
Update repr.lua
Reimplements something similar to the old repr: https://github.com/FAForever/fa/blob/5df582851a64ac8cc7545dab243ec6935c495605/lua/system/repr.lua
72c4aed
to
47aac38
Compare
47aac38
to
ee451ba
Compare
@maudlin27 / @relent0r you both use this function too. It may be interesting for you to look at these changes and share your thoughts. |
lua/system/repr.lua
Outdated
local gsub = string.gsub | ||
local fmt = string.format | ||
local _rawget = rawget | ||
local type = type | ||
local getmetatable = getmetatable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this diversity in variable naming. It was discussed 3 years ago and we still mix this and that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a link to the discussion? I haven't seen it.
lua/system/repr.lua
Outdated
} | ||
|
||
---@param v table | fa-class | fa-class-state | ||
local function fafTableToString(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjectToString
sounds more reasonable.
lua/system/repr.lua
Outdated
local type = type | ||
local getmetatable = getmetatable | ||
local debugGetInfo = debug.getinfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make upvalued functions of certain libraries as Pascal case then follow it.
Description of the proposed changes
More FAF-specific improvements to the inspect library:
__index
fields if they're the same as the table. This removes a lot of common recursive clutter (it is still possible to recurse, for example theBrain.CDR.Brain
orWorldView.view.WorldView
in the example below).Testing done on the proposed changes
Use this command on a Percival:
Example Output (Percival).txt
Use this command:
Example Output (main WorldView).txt
Additional context
The last version of the original repr printed class-specific data. I was lazy on implementing that, but it could be done by using a helper function instead of directly the names table. Still, in general these changes lay the foundations for class-specific data printing.
Checklist