Derp, I misread.
Die Martin Die
Just a hobbyist programmer.
- 0 Posts
- 4 Comments
Joined 2 years ago
Cake day: September 6th, 2023
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
Kinda.
Lua defines it implicitly only when you use the
function foo:bar(a, b, c) -- note the colon
syntactic sugar, which gets translated to
function foo.bar(self, a, b, c) -- note the period
In all cases,
self
is a regular variable name. You can even redeclare a new local with that name even when the old one is in scope.Edit: some typos
Die Martin Die@sh.itjust.worksto Programmer Humor@programming.dev•Python needs an actual default function14·16 days agoif debug.getinfo(1).what == "main" then -- ... end
Not that you’ll ever use it. No, seriously.
Edit: actually, they are not quite equivalent. This code just checks whether we are outside any function, not necessarily in the main file (i.e. not in a module). I don’t think there’s an equivalent to Python’s
__name__
in stock Lua.
Supposotory*