Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Variable Interpolation

Expand Messages
  • merlyn@stonehenge.com
    ... Jenda I would be a bit surprised if anyone wrote: Jenda sub foo { Jenda my $bar = shift(@_); Jenda ... Jenda and would wonder why. In this case
    Message 1 of 20 , Jan 3, 2006
    • 0 Attachment
      >>>>> "Jenda" == Jenda Krynicky <Jenda@...> writes:

      Jenda> I would be a bit surprised if anyone wrote:

      Jenda> sub foo {
      Jenda> my $bar = shift(@_);
      Jenda> ...

      Jenda> and would wonder why. In this case it's a generally accepted that the
      Jenda> @_ gets omited. OTOH, I'd never make use of the fact that outside
      Jenda> subroutines shift() means shift(@ARGV). That's something lots of
      Jenda> people doesn't remember and something that might break easily if I
      Jenda> tried to move the piece of code into a subroutine.

      I agree with you there. However, for a five line program:

      #!/usr/bin/perl
      my $from = shift;
      my $to = shift;
      if (-e $to) { rename $to, "$to~" or warn "cannot backup $to: $!"; }
      rename $from, $to or warn "Cannot rename $from to $to: $!";

      Will anyone really not know what "shift" is doing there? Or confuse
      it with shift(@_)?

      That's the point of defaults... they're the defaults because they're
      the most common thing you would do with that operator *in that context*.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    • Shawn Corey
      ... The key phrase being in that context . My issue is that the default depends on the context. If it was the same throughout the regardless of context, I
      Message 2 of 20 , Jan 3, 2006
      • 0 Attachment
        merlyn@... wrote:
        > That's the point of defaults... they're the defaults because they're
        > the most common thing you would do with that operator *in that context*.
        >

        The key phrase being "in that context". My issue is that the default
        depends on the context. If it was the same throughout the regardless of
        context, I wouldn't have a problem. The problem is that when I see a
        naked shift, I have to stop and remember the context. One more thing to
        worry about while reading a program.


        --

        Just my 0.00000002 million dollars worth,
        --- Shawn

        "Probability is now one. Any problems that are left are your own."
        SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

        * Perl tutorials at http://perlmonks.org/?node=Tutorials
        * A searchable perldoc is available at http://perldoc.perl.org/
      • merlyn@stonehenge.com
        ... Shawn The key phrase being in that context . My issue is that the default Shawn depends on the context. If it was the same throughout the regardless of
        Message 3 of 20 , Jan 3, 2006
        • 0 Attachment
          >>>>> "Shawn" == Shawn Corey <shawn.corey@...> writes:

          Shawn> The key phrase being "in that context". My issue is that the default
          Shawn> depends on the context. If it was the same throughout the regardless of
          Shawn> context, I wouldn't have a problem. The problem is that when I see a
          Shawn> naked shift, I have to stop and remember the context. One more thing to
          Shawn> worry about while reading a program.

          That's why I said "10 line program". If this were a 200 line program,
          I wouldn't bury "shift" in the middle, unless it was within 10 lines
          of the start of a subroutine.

          I believe it is reasonable to ask a programmer to look back about
          ten lines to figure out the general flow of the program. I don't
          think it's reasonable to have to maintain "state" further than that,
          which is why I argue for 10-20 line subroutines instead of most of
          the monoliths that I see most people write.

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
          See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
        • Shawn Corey
          ... Large monoliths have given me the willies ever since 2001: A Space Odyssey came out ;) -- Just my 0.00000002 million dollars worth, ... Probability is
          Message 4 of 20 , Jan 3, 2006
          • 0 Attachment
            Randal L. Schwartz wrote:
            > I believe it is reasonable to ask a programmer to look back about
            > ten lines to figure out the general flow of the program. I don't
            > think it's reasonable to have to maintain "state" further than that,
            > which is why I argue for 10-20 line subroutines instead of most of
            > the monoliths that I see most people write.
            >

            Large monoliths have given me the willies ever since "2001: A Space
            Odyssey" came out ;)


            --

            Just my 0.00000002 million dollars worth,
            --- Shawn

            "Probability is now one. Any problems that are left are your own."
            SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

            * Perl tutorials at http://perlmonks.org/?node=Tutorials
            * A searchable perldoc is available at http://perldoc.perl.org/
          • mail meda
            Hi Frnds, Thanks for your response. Bye. ... [Non-text portions of this message have been removed]
            Message 5 of 20 , Jan 5, 2006
            • 0 Attachment
              Hi Frnds,

              Thanks for your response.

              Bye.


              On 1/4/06, Shawn Corey <shawn.corey@...> wrote:
              >
              > Randal L. Schwartz wrote:
              > > I believe it is reasonable to ask a programmer to look back about
              > > ten lines to figure out the general flow of the program. I don't
              > > think it's reasonable to have to maintain "state" further than that,
              > > which is why I argue for 10-20 line subroutines instead of most of
              > > the monoliths that I see most people write.
              > >
              >
              > Large monoliths have given me the willies ever since "2001: A Space
              > Odyssey" came out ;)
              >
              >
              > --
              >
              > Just my 0.00000002 million dollars worth,
              > --- Shawn
              >
              > "Probability is now one. Any problems that are left are your own."
              > SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_
              >
              > * Perl tutorials at http://perlmonks.org/?node=Tutorials
              > * A searchable perldoc is available at http://perldoc.perl.org/
              >
              >
              > Unsubscribing info is here:
              > http://help.yahoo.com/help/us/groups/groups-32.html
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              >
              >
              >


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.