[Catalyst] html-widget bug or design?

Matt S Trout dbix-class at trout.me.uk
Wed Mar 1 19:29:41 CET 2006


On Wed, Mar 01, 2006 at 03:15:25PM -0300, Nilson Santos Figueiredo Junior wrote:
> On 3/1/06, A. Pagaltzis <pagaltzis at gmx.de> wrote:
> > Please don't. Every time I have to use such an API it makes me
> > cry. :-( Making the type of the return value dependent on its
> > value is a breathtaking pain in the rear end. It causes code
> > that's gunked up with gobs of `ref $foo eq 'ARRAY'` checks.
> 
> I'm not sure when you'd need to actually check anything like that.
> 
> If you want an array ref call it like:
> 
> my $result = Class->method;
> 
> If you want a list of values call it like:
> 
> my ($result) = Class->method;
> 
> I, myself, actually like this sort of API since it allows *me* to
> choose what's more convenient instead of relying on the module
> author's choice.

Unless you're running under Template Toolkit, in which case the choice is
always "list context".

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list