in reply to Re: Re: Is "ref $date eq 'ARRAY'" wrong? What a mess!
in thread Is "ref $date eq 'ARRAY'" wrong?

As I said, ref() should be only used with objects if you really want, explicity, an object blessed in the class FOO, soo, without care about inheritance.

> > But I never saw that ...
> try reading perldoc perlobj!

I know that this is possible, as I show in the previous node, what I said is that I never saw this in use! I never saw a code that want's to use the internal object data, HASH, ARRAY,... as a normal data! And I think, that shouldn't be used, since this is not a good thing when we are talking about OO.

Graciliano M. P.
"Creativity is the expression of the liberty".

  • Comment on Re: Re: Re: Is "ref $date eq 'ARRAY'" wrong? What a mess!

Replies are listed 'Best First'.
Re: Re: Re: Re: Is "ref $date eq 'ARRAY'" wrong? What a mess!
by d_i_r_t_y (Monk) on Dec 21, 2003 at 02:42 UTC
    As I said, ref() should be only used with objects if you really want, explicity, an object blessed in the class FOO, soo, without care about inheritance.

    it is poor form to mandate a specific class name for anything except establishing capability. to establish whether a thing can perform only 1 or 2 methods, UNIVERSAL::can( $thing, "doFoo") is more flexible than UNIVERSAL::isa( $thing, "Fooable") besides.

    I know that this is possible, as I show in the previous node, what I said is that I never saw this in use! I never saw a code that want's to use the internal object data, HASH, ARRAY,... as a normal data! And I think, that shouldn't be used, since this is not a good thing when we are talking about OO.
    try: grep -nr 'isa' /usr/lib/perl | grep -e 'ARRAY' -e 'HASH'

    HASH, ARRAY, etc are not internal object data, they are type names in the same way that an object's class name is a type. If i wished to replace all array refs in my code with objects of my shiny new sorted array class with its TIEARRAY interface, i could change only the calling method (to create the object instead of the array ref), put 'ARRAY' into @MySortedArray::ISA as a pseudo-class (read: interface or capability to act as an array), then any code which used UNIVERSAL::isa( $thing, 'ARRAY' ) to establish that $thing could be dereferenced as an array (through its tie interface) would continue to work unchanged, but code using ref( $thing ) eq 'ARRAY' would break and need recoding. and in my company's 170,000 line perl app, recoding hundreds of methods because of bad coding is A Bad Thing and a huge PITA.