Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it really make sense for ClassName to accept objects overloading stringification? #21

Open
tobyink opened this issue Oct 19, 2022 · 1 comment

Comments

@tobyink
Copy link

tobyink commented Oct 19, 2022

Consider:

has ua_class => (
  is       => 'ro',
  isa      => t('ClassName'),
  default  => 'HTTP::Tiny',
);

has ua => (
  is       => 'ro',
  isa      => t('Object'),
  default  => sub { shift->ua_class->new() },
);

If somebody sets ua_class to an object overloading stringification, and the stringification yields a valid classname, then what will ua be?

This seems a source for very hard to diagnose bugs, especially as things like warn $self->ua_class will hide the issue.

@autarch
Copy link
Member

autarch commented Nov 9, 2022

This is a good question, but I don't have a good answer. I feel like I could make an argument either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants