Perl 6.x , please offer PREPEND as well as APPEND

Discussion in 'Perl Misc' started by Mr P, Jan 31, 2006.

  1. Mr P

    Mr P Guest

    Dear Damian, Larry, et al:

    The asymetric PREPEND and APPEND should be addressed in 6.x:

    # append a string, very nice
    $song .= ' Her Majesty The Queen';

    # prepend a string - YUK, ugly, [1]
    $song = ' Her Majesty The Queen ' . $song;

    # new and improved prepend a string - YAY, posh
    $song =. 'Her Majesty The Queen ';
    # or to be consistent with other $a x= $b syntax, perhaps something
    like...
    $song |= 'Her Majesty The Queen ';


    ******************************************************

    If you offer tea you should serve crumpets as well!

    Thank-You for your kind attention,

    Mr P

    [1] - every mathmatician or logician has to flinch everytime they
    encounter this syntax. As programmers we understand what it's up to of
    course, but in general terms:

    a = b + a

    is ONLY true for b=0, (or b='' in the case of a string) which in our
    case is NOT true.
     
    Mr P, Jan 31, 2006
    #1
    1. Advertising

  2. Mr P

    Paul Lalli Guest

    Mr P wrote:
    > [1] - every mathmatician or logician has to flinch everytime they
    > encounter this syntax. As programmers we understand what it's up to of
    > course, but in general terms:
    >
    > a = b + a
    >
    > is ONLY true for b=0, (or b='' in the case of a string) which in our
    > case is NOT true.


    Riight, that's because a mathematician uses = to mean one thing, and
    programmers use it to mean something else. If you use the
    corresponding operators, the axioms hold just fine:

    $a eq $b . $a only for $b equalling '';
    $a == $b + $a only for $b equalling 0.

    I'm very confused as to what your point is.

    Paul Lalli
     
    Paul Lalli, Jan 31, 2006
    #2
    1. Advertising

  3. > Mr P wrote:
    >> [1] - every mathmatician or logician has to flinch everytime they
    >> encounter this syntax. As programmers we understand what it's up to
    >> of course, but in general terms:
    >>
    >> a = b + a
    >>
    >> is ONLY true for b=0, (or b='' in the case of a string) which in our
    >> case is NOT true.


    I know at least mathematician (with two Ph.D.s who is not bothered by this
    at all. Hence, your statement is false.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Jan 31, 2006
    #3
  4. Mr P

    Guest

    "Mr P" <> wrote:
    > Dear Damian, Larry, et al:
    >
    > The asymetric PREPEND and APPEND should be addressed in 6.x:
    >
    > # append a string, very nice
    > $song .= ' Her Majesty The Queen';
    >
    > # prepend a string - YUK, ugly, [1]
    > $song = ' Her Majesty The Queen ' . $song;


    Not only ugly, but also slow if $song is large. You can use the
    four argument substr to (potentially) make it faster, but then it is
    even uglier.

    But I don't see a tremdous need for a new operator here. If you are doing
    a lot of prepending, chances are you are doing something wrong, I'd think.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Jan 31, 2006
    #4
  5. wrote

    > Not only ugly, but also slow if $song is large. You can use the
    > four argument substr to (potentially) make it faster, but then it is
    > even uglier.


    Well, there's still the simple possibility of putting that into a new
    infix operator.


    p

    --
    Hear the chants of old powers, the weak fall on their swords.
    Nature is above all morals, destiny a shameless whore.
    -- Sol Invictus, Black Easter
     
    Robert Sedlacek, Jan 31, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    2,206
  2. flamesrock

    how to prepend string to a string?

    flamesrock, May 31, 2005, in forum: Python
    Replies:
    6
    Views:
    16,341
    newcoder
    May 31, 2005
  3. Replies:
    37
    Views:
    2,084
    Flash Gordon
    Jan 9, 2006
  4. HYRY
    Replies:
    10
    Views:
    625
    Bruno Desthuilliers
    Sep 26, 2007
  5. dspfun

    Prepend name to function names?

    dspfun, Jan 29, 2008, in forum: C Programming
    Replies:
    8
    Views:
    885
    dspfun
    Jan 29, 2008
Loading...

Share This Page