497
submitted 1 week ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 6 points 1 week ago* (last edited 1 week ago)

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

[-] [email protected] 3 points 1 week ago

I don't see how what you said is inconsistent with me saying "self" is special in lua. Note that I did not say it's a keyword.

[-] [email protected] 2 points 1 week ago

Derp, I misread.

this post was submitted on 08 Jun 2025
497 points (97.7% liked)

Programmer Humor

36533 readers
215 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS