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

Owner: Nobody in particular
Requestors: perl [...]

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

Subject: eq_predicates
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-27254-1400314369-377.0-0-0 [...]>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 747
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 infrastructure.

Please report any issues with to