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

M

Mr P

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.
 
P

Paul Lalli

Mr said:
[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
 
A

A. Sinan Unur

Mr said:
[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
 
X

xhoster

Mr P said:
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
 
R

Robert Sedlacek

(e-mail address removed) 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top