Skip Menu |

This queue is for tickets about the Hades CPAN distribution.

Report information
The Basics
Id: 133224
Status: new
Priority: 0/
Queue: Hades

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

Bug Information
Severity: Normal
Broken in: 0.07
Fixed in: (no value)



Subject: Predicates behave unexpectedly
Usually predicates are implemented as: exists( $self->{attr} ) But Hades implements them as: !! $self->{attr} An edge case is that Class::XSAccessor usually behaves as: defined( $self->{attr} ) Though Class::XSAccessor does allow you to create predicates using exists() too. If the difference between Hades and Moose/Moo/Mouse/etc is unintentional, it should be fixed. It should be pretty easy -- just replace the "!!" in build_predicate with "exists". If the difference is intentional, it should be documented, both in the Hades documentation and in the documentation that Hades generates for classes. Examples of predicates in Moo, Moose, Mouse, and Hades are attached.
Subject: hades-test.pl
use strict; use warnings; use lib '.'; { package Foo1; use Moo; has myattr => ( is => 'ro', predicate => 1 ); } my $foo1 = Foo1->new( myattr => 0 ); warn "bad Moo" unless $foo1->has_myattr; { package Foo2; use Moose; has myattr => ( is => 'ro', predicate => 'has_myattr' ); } my $foo2 = Foo2->new( myattr => 0 ); warn "bad Moose" unless $foo2->has_myattr; { package Foo3; use Mouse; has myattr => ( is => 'ro', predicate => 'has_myattr' ); } my $foo3 = Foo3->new( myattr => 0 ); warn "bad Mouse" unless $foo3->has_myattr; require Hades; Hades->run({ eval => q{ Foo4 { myattr :pr } }, }); require Foo4; my $foo4 = Foo4->new( myattr => 0 ); warn "bad Hades" unless $foo4->has_myattr;