A question about a truthiness check in awesome/lib/wibox/widget/base.lua #3992
internet-account2
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe this is just a stupid question but I can't resist asking: Why does this line check
widgets?https://github.com/awesomeWM/awesome/blame/691e36425a645e54402cb04efc4c2b00d73051bd/lib/wibox/widget/base.lua#L770
widgetscomes fromparse_table, which always returns a table, because it either returns a table that function created itself, or a table it gets from gears.table.from_sparse, which itself always returns a table.So that line reads to me as
(Also, if
maxis greater than 0, thenwidgetsshould definitely be not nil?..)Is it written that way to be "future-proof", so in case any code might get changed so that
widgetscould potentially become nil it already covers that case?Or is there ever any chance that
widgetsin this case could ever be nil that I'm missing (while simultaneouslymax > 0)?The only reason I stumbled upon this line is because I got bitten by a bug that got fixed ~4 years ago because I'm still on the "stable" 4.3 version from the arch repo (shame on me I guess) so I was questioning my sanity for the last few hours 🫠 ( 7bc3ec4 )
(Also the commit comment of that fix is strictly speaking false ("
drillwill be called twice"), because the wrapping function doesn't have to use the declarative way. Not that it really matters, just another small nitpick ^^)Beta Was this translation helpful? Give feedback.
All reactions