On 2/26/07, Yuval Kogman <[EMAIL PROTECTED]> wrote:
On Mon, Feb 26, 2007 at 17:47:23 +0100, demerphq wrote:
> On 2/26/07, Joshua ben Jore <[EMAIL PROTECTED]> wrote:
> >I'm of the opinion that it is clear and blatantly an error to ever use
> >ref as a boolean.
>
> One liners and minor snippets where you control the input data would
> be an exception IMO.


Are you guys serious?

I am. Actually my view is that using ref at all unless you control the
input is an error.

Too many times ive bumped into dumbass code that does

if (ref($ob) == 'ARRAY') {...}

so that i cant pass an object into the routine, for no good reason at all.

Likewise with ref in boolean context, I almost never want the object
to be able to lie to me.

When has this ever been an issue in practice? The only time it has
been an issue the intended behavior was in fact that the object
really not be treated as an object (Scalar::Defer). Someone trying
to bless into these classes is obviously doing it for that intended
behavior.

Well i am biased in that ive spent a ton of time on data serialization
modules where i never want to be lied to.

If i dont care what the object is or whether they passed in an object
then i wont test for it at all.

Turning this around for a moment, when does it make sense to use ref
and yet at the same time not care that it might lie?

Yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

Reply via email to