Re: Confused about Value and Item
[email protected] (Ricardo Signes)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
* Ovid <[email protected]> [2012-03-22T17:08:31] > In trying to explain this, I got stuck on "Item" and "Value". I have the > following note about them: We discussed this briefly on Twitter. For the record, it was around https://twitter.com/ovidperl/status/182936878192934912 > A word about the types in Moose::Util::TypeConstraints. "Any" means "anything" > (duh). An "Item" is the same as "Any" and in your author's consultation with > Moose experts, there was confusion expressed as to why these were different My guess is that it's vestigal from some concept of validating non-scalars. But I don't know. "It never comes up." > A "Value" is "anything which is defined and not a reference". But since > everything which is a "Value" is also a "Str" (String) type, it's also > unclear why "Value" was included, except for possibly defining future types > which may apply. As we discussed, this is not true. Str is a subset of Value, and not identical to it. For example, C<< *main >> is accepted by Value and not by Str. There's nothing too weird about this. "foo" is a Str but not a Num, but we don't need any other type just to cover it. (NonNumStr? AlphanumStr?) Value is like that. I'm not sure I've ever seen Value used to good effect. It's not a particuarly useful thing to validate. But it's a meaningful part of the hierarchy, and it got named. It could be useful if we end up with other non-reference values someday, but I wouldn't bother with it. "Value" is "anything which is defined and not a reference." Almost any time you say this, you really mean Str (a string), as the only things that fall into Value and not Str are pretty esoteric. -- rjbs
signature.asc
(application/pgp-signature, 490 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJPa5bDAAoJEOYby6cMccU5eeQH/3OYs+trKDXniBZzU4Xq1gEO TyNi0OJiIa+L+7FiaDaJf59NcSB881cmPVqqCTlEVClm+YBlEkD/dg/dWawZJJg1 pHC41xV9A3g/MzJiGaQ8+67y1Kz/DWvuGjruqi0gdRcgNM2gg9Pg8CPSzENTvjad IxLLGO6lw5p30cV2m2VOK9YshG9iyy8QiosHCpL2d/A57LVwv53c94Xs8CxrFvK8 jG/gx2y/CRx2SnkVzHq4VAsWb46CdSAlwrv2U77BOkYe1m5SQHxiNGqNUncas7n7 bJQXFHgeEZLZ/3T+sM1rZbYAE6znihRnMN/F0ws/12Gfd5ULe0PtQBK8XKm5064= =U/RB -----END PGP SIGNATURE-----