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

Re: Types in Cor (and Perl)

Thread Previous | Thread Next
From:
Ovid via perl5-porters
Date:
July 14, 2020 07:29
Subject:
Re: Types in Cor (and Perl)
Message ID:
722074574.908744.1594711768690@mail.yahoo.com
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:

       my TYPE VARLIST : ATTRS

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.
Best,Ovid
-- IT consulting, training, specializing in Perl, databases, and agile developmenthttp://www.allaroundtheworld.fr/. 
Buy my book! - http://bit.ly/beginning_perl 

    On Tuesday, 14 July 2020, 03:35:14 CEST, David Green <david.green@pl-comme.ci-comme.ca> 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.
  https://metacpan.org/pod/Lexical::Types
  
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About