I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-11-20 10:55:44-08 by earl
More types?
Have you considered adding more options to the 'Type' attribute?

1. If I want the type to be a scalar, I can say 'Type' => '', right? I think that's covered.

2. If you have 'NUMERIC', why not have 'INTEGER' ?

3. In my program, I have a lot of "POSITIVE' (Integers > 0). Some people may like 'NATURAL' (Integer >= 0).

4. I'm not a big fan of implicit conversion. (The software engineer in me says implicit conversion can mask errors.) I wish there was a way to specify 'ARRAY', where anything but an array ref is an error.

If you like these ideas, but you don't have the time to add them, I may be able to work on adding them.

Earl
Direct Responses: 1369 | Write a response
Posted on 2005-11-21 16:58:34-08 by jdhedden in response to 1355
Re: More types?
> Have you considered adding more options to the 'Type' attribute?

Because you asked, I added custom type checking in Object::InsideOut v1.13. Check here for the announcement.

> 1. If I want the type to be a scalar, I can say 'Type' => '', right?

No, that results in no type checking at all. Using custom type checking in the OIO 1.13, you can achieve SCALAR type checking like this:
my @data :Field('Accessor' => 'data', 'Type' => sub { ! ref($_[0]) } );

> 2. If you have 'NUMERIC', why not have 'INTEGER' ?

I originally put in 'NUMERIC' because it was so simple using Scalar::Util::looks_like_number(). Other numerical checks would have taken more code. Now, with custom type checking you can define whatever you need. See the announcement post for an example of INTEGER type checking.

> 3. In my program, I have a lot of 'POSITIVE' (Integers > 0).

Here's an example for that:
package My::Class; { use Object::InsideOut; sub positive : Private { return (Scalar::Util::looks_like_number($_[0]) && ($_[0] > 0)); } my @num :Field('Acc' => 'num', 'type' => \&My::Class::positive); }

> 4. I wish there was a way to specify 'ARRAY', where anything but an array ref is an error.

Okay. I added two new types for that: 'ARRAY_REF', and 'HASH_REF'

Thanks for the inspiration. Hope it all works for you.
Direct Responses: 1377 | Write a response
Posted on 2005-11-22 05:10:03-08 by earl in response to 1369
Re: More types?
I am VERY thankful!
Direct Responses: Write a response