Mailing List Archive

perlclass is unclear regarding class attributes
The grammar described is:

class NAME [VERSION] {BLOCK | ;}

But it is unclear where attributes should come in the versioned version.

Should it be

class NAME [ATTRIBUTES] [VERSION] {BLOCK | ;}

or

class NAME [VERSION] [ATTRIBUTES] {BLOCK | ;}

I assume the first version is right, but would be nice to clear and include
attributes to the syntax block.
Re: perlclass is unclear regarding class attributes [ In reply to ]
On Sun, Jul 9, 2023 at 6:53?AM Alexandr Evstigneev <hurricup@gmail.com>
wrote:

> The grammar described is:
>
> class NAME [VERSION] {BLOCK | ;}
>
> But it is unclear where attributes should come in the versioned version.
>
> Should it be
>
> class NAME [ATTRIBUTES] [VERSION] {BLOCK | ;}
>
> or
>
> class NAME [VERSION] [ATTRIBUTES] {BLOCK | ;}
>
> I assume the first version is right, but would be nice to clear and
> include attributes to the syntax block
>

Due to how the Perl parser works, we have to have the version immediately
after the class name. The attributes must not come before the version. (at
least, this is what I recall from Paul Evan's explanation to me).

That being said, I just filed two Perl bugs I found when writing one-liners
to show how it works. https://github.com/Perl/perl5/issues/21221 and
https://github.com/Perl/perl5/issues/21222

Best,
Ovid


--
Curtis "Ovid" Poe
--
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/
Re: perlclass is unclear regarding class attributes [ In reply to ]
On Sun, 9 Jul 2023 08:53:05 +0400
Alexandr Evstigneev <hurricup@gmail.com> wrote:

> The grammar described is:
>
> class NAME [VERSION] {BLOCK | ;}
>
> But it is unclear where attributes should come in the versioned
> version.
>
> Should it be
>
> class NAME [ATTRIBUTES] [VERSION] {BLOCK | ;}
>
> or
>
> class NAME [VERSION] [ATTRIBUTES] {BLOCK | ;}
>
> I assume the first version is right, but would be nice to clear and
> include attributes to the syntax block.

Ahyes, the documentation doesn't make that clear. I'll add something.

https://github.com/Perl/perl5/pull/21223

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/