in reply to Re: Is "ref $date eq 'ARRAY'" wrong?
in thread Is "ref $date eq 'ARRAY'" wrong?
When you check ref() you impose a no-blessings and no-subclassing requirement which really isn't all that friendly or perlish.
I don't agree.
First off, you don't really "impose a no-blessings and no-subclassing requirement"; you just decide that you won't be responsible for it. There is nothing preventing a user of your code from writing something like
my $original_package = ref $object; bless $object, 'ARRAY'; call_sub_that_expects_array_ref( $object ); bless $object, $original_package;
I think it's probably more prudent to let your user take responsibility for treating his $object like an array reference. You can be permissive, but you might make it hard to catch some subtle bugs and you may be encouraging maintenance problems. Besides, the practical benefits are likely to be very few.
Edit: Minor grammatical fixes.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Is "ref $date eq 'ARRAY'" wrong?
by diotalevi (Canon) on Dec 21, 2003 at 04:10 UTC | |
by sauoq (Abbot) on Dec 21, 2003 at 08:02 UTC |