Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: my least favorite perl feature

by Zaxo (Archbishop)
on Feb 05, 2003 at 20:55 UTC ( #232922=note: print w/replies, xml ) Need Help??

in reply to my least favorite perl feature

Time to breathe in the Zen.

Perl stringifies and numifies things at need. Scalars silently become strings for printing, numbers for arithmetic.

When you choose between == and eq don't think of it as forced by the nature of the scalar. Think of it as choosing for yourself how the comparison will be done.

After Compline,

Replies are listed 'Best First'.
Re: Re: my least favorite perl feature
by waxmop (Beadle) on Feb 05, 2003 at 21:40 UTC

    After breathing some Zen, I still wish there was some sort of 'object equivalence testing operator' in Perl. I could use it to compare two hashes, or two arrays, or objects, or whatever, and it would give me a same/not-same response.

      Well, the question "when are two arrays the same" has never been answered in a way all people could agree on.

      Personally, I find the current behaviour of

      if (@array1 == @array2)
      very useful. I wouldn't want to miss it.

      Furthermore, you'd have a hard time convincing me that you need to do less work for redefining an operator than for defining a function. Why not create a function that compares two arrays?

      Lastly, perl6 will have a supermatching operator. It will do all kinds of different things, depending on the types of its operands. Perhaps your idea of comparing arrays is one of the possible options.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://232922]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2021-02-24 21:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found