On Mon, 5 Jun 2023 at 05:09, Alexandru Pătrănescu <dreal...@gmail.com> wrote:
> > How about a keyword/variable to the current executing closure that works > also if you refactor it to a function or a method. > Just like self for a class we can have a keyword like fnself [..] This seems quite appealing to me, and is imho more idiomatic and ergonomic than the other proposals. Keywords naturally avoid conflicts with user variables, and remove the need for each author to pick a name for their closure and the inevitable preferences, automation, and disagreements that will arise from that. On the other hand, we've seen from *match()* how disruptive a new keyword can be as they clash as well, with function names instead of variables. Building on an existing keyword or soft-reserved naming convention would avoid that. In terms of global constants, we have double underscores which is in the proposal already but feels unnatural as others have indicated already. In terms of local constants, I believe we authors generally prefer uppercase names, and we have one built-in special constant that's lowercase: *self::class*. Perhaps *self::fn* or *self::callee*? The latter borrows the closure terminology form JavaScript (arguments.callee, which does the same thing). -- Timo Tijhof https://timotijhof.net/