-
Notifications
You must be signed in to change notification settings - Fork 237
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. |
These changes are fine in general. It appears however that calling The reason is that at the moment the Brain reference is recursively printed too. And that can hold a lot of information, especially for AIs. |
For the uninitiated what does this do for us exactly compared to the repr function now? |
Maybe it is better to skip only brains and blueprints (if they're not the root), and create a flag for that specifically? There could be a wide variety of tables with metatables that we'd want to avoid. Alternatively the proper solution would be to be like deepcopy and have a "backrefs" table that tells us whether we've seen a table or not before. |
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