in reply to Re^4: The trap of reference numification
in thread The trap of reference numification

So, you're proposing that the warning should warn whenever a reference is numified, save when the numified value is used in a == (any other exceptions)? Talk about a weird exception to a weird case. And you think we get laughed out now ...

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re^5: The trap of reference numification

Replies are listed 'Best First'.
Re^6: The trap of reference numification
by Roy Johnson (Monsignor) on Nov 11, 2005 at 23:14 UTC
    At issue is determining when something is likely to be programmer error. That's a very twisty problem. Your post suggests that you think it should be straightforward and elegant. Whose laughter are you concerned about?

    Do you disagree with my suggestion, and if so, have you got some stronger argument than ridicule?


    Caution: Contents may have been coded under pressure.
      The correct fix is to have references throw an error when numified or stringified. Period, end of story. If you want to stringify a reference, use ref(). If you want to numify a reference, use ref_addr(). If you want something unique, use some combination of the two.

      Solve the problem. Don't throw a random bandaid on it.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

        He proposed that. You then gave situations where you don't do what you just suggested to to. I think it might help if you stated your view a little clearer, or at least mentioned that you changed views or the poor OP is going to go crazy trying to talk to you.


        ___________
        Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;

        I dont think this is the correct fix. It totally overlooks overloading and it ignores that people often want to stringify or numify refs legitimately. And refaddr() on older perls uses stringification to do its job.

        ---
        $world=~s/war/peace/g

        Solve the problem. Don't throw a random bandaid on it.
        As far as I see it, the problem is a programmer using an ambiguous variable name, $row, of which he can't remember whether that's a count, or a reference to an array.

        The bandaid is introducing a warning in Perl.

        I'd say the programmer should fix his naming scheme. Doesn't Perl Best Practises have a say on naming variables as well?

        Perl --((8:>*