otikik
Joined 13 years ago
Karma
7,132
Submissions
2,708
Member since
Mar 19
Joined 13 years ago
Sir, I believe you have not watched it.
Just today I was served a clearly AI-generated Halloween ad for Coca-Cola.
Anyway...
Numerical loops in Lua are inclusive:
for i=1,#t do t[i]=0 end
On the example above the i starts at 1 and goes up to (and including) the length of t.With 0-based indexes, and that numerical loop format, it would be minus-one everywhere:
for i=1,#t-1 do ...To me it is more about expressiveness and usage of basic language features. For example here's how a text field is set up currently.
ito.TextField(draft)
:label("Name")
:focused()
:on_submit(function(value)
if value:match("%S") then
phase.value = "review"
end
end)
:on_cancel(function()
phase.value = "choose"
end),
The field is created on the first line, and then altered further with subsequent method calls that alter it. This reads like someone very used to Rust (and its Builder pattern) and then translating it verbatim to Lua. A more native Lua interface for me would look like this: ito.TextField(draft, {
label = "Name",
focused = true,
on_submit = function(value)
if value:match("%S") then
phase.value = "review"
end
end,
on_cancel = function()
phase.value = "choose"
end),
})
As in: just pass a table to the builder. And if they ned to modify it later, they can just do: some_textfield.on_cancel = <some other function>
No need to "guard" the internal table with those extra methods.I would like us to find a way to live without killing our host.
We live in different worlds
It is not a joke! The naming is so bad so it sounds like a joke. So people like the author assume it is a joke and move on without suing them. They are counting on that.