[Chicago-talk] Dynamic method call

Steven Lembark lembark at jeeves.wrkhors.com
Fri Nov 7 14:24:35 CST 2003

> If we aren't supposed to use them, then why doesn't it say so in the
> docs. I use prototypes to keep users from giving incorrect arguments to
> functions. If they provide the incorrect number of arguments, it's caught
> at compile time and they can quickly fix it. Without prototypes, I would
> need to manually write code to check that they gave the right arguments,
> or I could ignore it and then the user could spend much wasted time
> trying to figure out why their code is mysteriously not working the way
> it's supposed to.

For one rather nice way: perldoc Class::Contract;

The manual checks are my preference only becuase I can give
more useful error messages than the compiler does. In most
cases with perl the arg's are on a list or a referent to some
type. Aside from knowing to pass in a hash referent (vs array
ref) or that arg's are required, the really useful error
messages don't start until after the values themselves have
been validated, which prototypes cannot do for you. Once
you have to validate the arg's anyway, what's the difference
in adding 2-3 lines to check for a correct ref type?

Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 888 359 3508

More information about the Chicago-talk mailing list