Empty Tables are Unclear in the Expressive Output Window

As a Roblox developer, it is currently too hard to determine if tables printed in the Expressive Output Window are empty.

Problems

Expand Button (>) Implies Non-emptiness for Empty Tables

print{} and print({}) will print an empty table. In the Expressive Output Window, it displays as:

image
Even though the table is empty, the window still displays the expand button. There’s nothing to expand here. I’m tricked into thinking there’s more to see here, so I click on the expand button button needlessly.

“{}” Implies Emptiness for Non-empty Tables

Printing a table with any contents, such as {1, 2, 3} renders the same as an un-expanded empty table. For instance:

image
This is also misleading. In Lua, {} declares an empty table. In this example, the table isn’t actually empty, so my code-focused brain is fooled into thinking the printed table is empty. Furthermore, my eyes are already trained to ignore the preceding expand button (>) because of command bar inputs appearing in the output.

Feature Request

For an empty table, a significantly more user-friendly representation is just {}, or the display equivalent of print("{}"):

image
(This is how an empty table should look: no misleading expand button, and nothing between the curly braces.)

For non-empty tables, a sensible solution is an ellipsis (…) between a pair of curly braces: { ... }

  • Indicates an abbreviation, just like plain English
  • It’s valid Lua syntax, which is in-line with the representation the Output already uses. This helps a code-focused reader ignore what isn’t a problem.
  • Mirrors what other IDEs will do when abbreviating code and code-like text. For example, see JSON in Visual Studio Code:
    image
    (Here, the data key is contracted: a grey ellipsis is displayed on the first line, and clicking it re-expands the JSON object)
  • A bigger click box than a single character. This makes use of horizontal space is probably not necessarily being used anyway.

Use Cases

(Because no good feature request is good without them.)

Printing Many Tables, Some Of Which Are Empty

If you’re printing many tables that may or may not be empty, you probably want some kind of indication so you don’t have to open them all to check. You also would not need to expand all tables in order to do this, as you’ll some indication if a table is worth checking (or, rather, can be checked at all).
(“But wait!”, you might say, “Why not check auto-expand tables by default?” And you’d be right, but alas you’d be forced to see all non-empty tables contents where you might only want to inspect one at a time. You’d also use double the amount of lines for empty tables, which means at worst you’ll be seeing half as many tables.)

Browsing Nested Tables, Which May Contain Empty Tables

Say you’re browsing a heavily nested tree of tables. You may be misled into thinking some of your unexpanded sub-tables are empty, as you’ve expanded the root table (what was directly passed to print), but not necessarily its sub-tables. You might believe that expanding the root table expands all of the sub-tables, but you’d be mistaken! By seeing {} or {...} you’ll know for sure and not go looking down branches of your table that have nothing to show.

tl;dr

When I print a table and view it in the Expressive Output Window with auto-expand off, at the very least I should be able to tell if the table is empty:

  • Hide the expand button for empty tables
  • Use an ellipsis for non-empty tables

If this issue is addressed, it would improve my development experience because I’ll be able to tell if non-expanded tables in the Expressive Output Window are empty without having to expand them.

23 Likes

I agree! A week ago, I kept thinking there was a bug in my code because it looked like it was outputting an empty table.

5 Likes