in reply to Re: Re: Re: How do I determine the underlying type of an Object?
in thread How do I determine the underlying type of an Object?

Anyone blessing something into or using a package named HASH needs to be punished.

Why ;-) The namespaces for packages and Perl's fundamental types are different. If somebody wants to use them they are free to do so. They have sick and strange minds - but it's legal.

Since there is a good way of finding out the underlying type (reftype) I would prefer to use that instead of something hand rolled that breaks on odd package names, tied variables, packages with overloaded stringification, etc.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: How do I determine the underlying type of an Object?
by Juerd (Abbot) on Apr 20, 2003 at 13:46 UTC

    If somebody wants to use them they are free to do so.

    Yes, and that somebody would be a fool for doing so.

    but it's legal.

    Legal, but stupid. Just like using symbolic references instead of real ones is legal, but stupid. And many other things that are both possible and to be avoided.

    there is a good way of finding out the underlying type (reftype)

    Scalar::Util is quite heavy. I know Perl hackers are supposed to not care about memory usage, but I do think pulling in 400 kB is a bit too much to work around potential problems that in practice don't exist.

    I'm willing to sacrifice memory for speed. Not to work around unlikely, theoretical problems :)

    Juerd
    - http://juerd.nl/
    - spamcollector_perlmonks@juerd.nl (do not use).
    

      Just like using symbolic references instead of real ones is legal, but stupid.

      No, No, NO! Symbolic references are not stupid, just extremely powerful. There are many perfectly smart reasons to use symbolic references. It just so happens that 99% of all of the actual usages are stupid.

      It's kinda like saying C-style for-loops are stupid. Well, for the most part, Perl-style foreach-loops do whatever C-style ones do and better with more checking and the like. And, in those cases, it is stupid to use the C-style one. But, and I'm sure I'm not alone, there are a ton of "boundary" cases where the C-style one may be preferable for a number of reasons (like the Perl-style one doesn't do what I need, etc).

      Never use absolutes - there's always a counter-example. *grins*

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

        No, No, NO! Symbolic references are not stupid, just extremely powerful. There are many perfectly smart reasons to use symbolic references. It just so happens that 99% of all of the actual usages are stupid.

        Please note that I said symbolic references instead of real ones is legal, but stupid.. It's okay to use them if real references are not an alternative.

        I did not say using symbolic references stupid no matter what. I use symbolic references in a lot of places. Just not where real references are usable.

        Juerd
        - http://juerd.nl/
        - spamcollector_perlmonks@juerd.nl (do not use).