develooper Front page | perl.perl5.porters | Postings from August 2023

Signature attributes

Thread Next
August 7, 2023 11:58
Signature attributes
Message ID:
Hi all,

Currently, the following is a syntax error:

    sub foo ($bar :myAttr) {...}

This has proven to be a blocker for some projects which use attributes on
declarations. For example, the Oshun project ( to create dynamic runtime data checks
had to jump through a lot of hoops to make this work:

    sub customer :returns(OBJ[My::Customer] | UNDEF)  ( $nth :of(UINT) ) {

If we had attributes for signatures, it wouldn't be an unholy mess of PPR
and Filter::Simple.

How difficult would it be to allow subroutine arguments to accept

Alternatively, perldoc -f my allows my TYPE VARLIST, but sub foo (INT $bar)

    A signature parameter must start with '$', '@' or '%' at -e line 1

But TYPE isn't currently used much, so I'm guessing that's probably of less
value, though we've considered that syntax for the Oshun data checks.

Curtis "Ovid" Poe
CTO, All Around the World
World-class software development and consulting

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About