develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Types in Cor (and Perl)

Thread Previous | Thread Next
Ovid via perl5-porters
July 14, 2020 07:29
Re: Types in Cor (and Perl)
Message ID:
David asked:
> Is there any reason not to use the existing syntax for types?
>  my Foo::Bar $x;
I deliberately avoided that because of this from perldoc -f my:


The exact semantics and interface of TYPE and ATTRS are still evolving.  TYPE may be a bareword, a constant declared with "use constant", or "__PACKAGE__".  It is currently bound to the use of the fields pragma, and attributes are handled using the attributes pragma, or starting from Perl 5.8.0 also via the Attribute::Handlers module.  See "Private Variables via my()" in perlsub for details.
So there's already some behavior attached to it and I was concerned about hijacking that behavior for something else and possibly breaking existing code.
-- IT consulting, training, specializing in Perl, databases, and agile development 
Buy my book! - 

    On Tuesday, 14 July 2020, 03:35:14 CEST, David Green <> wrote:  
 Is there any reason not to use the existing syntax for types?
  my Foo::Bar $x;

"Existing" because Perl already understands this (any perl5, I think; 
certainly as far back as 5.8).  It doesn't *do* anything, but perl can 
parse it (and will warn if there is no Foo::Bar package).

You can even make it do something with Vincent Pit's Lexical::Types.
Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About