in reply to perl 5.38: can the body of a class declaration contain arbitrary code?
Also: it looks like the my variables there are essentially "class static" members — so called in other languages e.g. C#. Is that an accurate characterization?
Pretty much yes. There is a discussion whether the class system needs its own syntax for "class static" members, but this is about convenience details which are not yet implemented: A "field" in Object::Pad can get attributes like :reader which will create appropriate accessor functions. You might want to permit a field $foo :static :reader, but there was some opposition against my $foo :reader which would make the syntax of the existing my keyword depend on the context. Damian Conway points out that a my variable is a private implementation detail, but a static field with a reader is part of the class interface (and maybe subject to inheritance). As far as Perl 5.38 is concerned, the distinction doesn't exist.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl 5.38: can the body of a class declaration contain arbitrary code?
by jdporter (Paladin) on Jul 05, 2023 at 13:27 UTC | |
by haj (Vicar) on Jul 05, 2023 at 14:40 UTC | |
by jdporter (Paladin) on Jul 05, 2023 at 18:59 UTC | |
by haj (Vicar) on Jul 05, 2023 at 22:18 UTC | |
by jdporter (Paladin) on Jul 05, 2023 at 22:35 UTC | |
|