Skip Menu |
 

This queue is for tickets about the Class-XSAccessor CPAN distribution.

Report information
The Basics
Id: 95726
Status: new
Priority: 0/
Queue: Class-XSAccessor

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: eq_predicates
Download (untitled) / with headers
text/plain 747b
I'd really like to be able to define some predicates along these lines: use Class::XSAccessor eq_predicates => { is_pass => [ status => 'pass' ], is_fail => [ status => 'fail' ], }; Which would be equivalent to: sub is_pass { $_[0]{status} eq 'pass' } sub is_fail { $_[0]{status} eq 'fail' } Why? Because currently the pure-Perl functions above are measurably slower than: if ( $obj->status eq "pass" ) { ... } And I'd really like to encourage a programming style of: if ( $obj->is_pass ) { ... } ... which leads to fewer magic constants scattered around code, and fewer typos causing hard to detect errors. Making these predicates faster using Class::XSAccessor would be a big selling point in their favour.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.