Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

Re: m/// (was [PATCH] Functional substitution (s///f) )

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


alfie at h4c

Nov 25, 2009, 1:30 PM

Post #1 of 7 (401 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) )

Hi guys,

On Thu, November 26, 2009 3:28 am, Jim Cromie wrote:
> On Tue, Nov 24, 2009 at 3:37 PM, <hv [at] crypt> wrote:
>> David Caldwell <david [at] porkrind> wrote:
>> :  I wrote a patch to scratch an itch I've had over the years. The patch
>> :adds a new flag to s/// ("f") to make it functional instead of
>> destructive.

>
> perhaps s///f should be spelled
> m///
>
> since the match doesnt change the string,
> it makes more mnemonic sense than substitute /// fake

A couple of weeks ago, this is exactly what I was trying to convince the
guys at work what I needed Perl to do in this situation. Instead, they
called me a heathen and chased me out the door with pitchforks. I'm glad
other people see the need in this one.

s///f looked like exactly what I wanted, but kinda ugly. m/// just makes
sense!

Alfie


xdaveg at gmail

Nov 25, 2009, 7:56 PM

Post #2 of 7 (379 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

>> perhaps   s///f    should be spelled
>>               m///

If we're going to bike-shed it, I vote to add a new *intro* character
instead of "m" and "s".

my $foo = $bar =~ f/one/two/;

-- David


hdp.perl.p5p at weftsoar

Nov 25, 2009, 8:44 PM

Post #3 of 7 (374 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

Excerpts from David Golden's message of Wed Nov 25 22:56:56 -0500 2009:
> If we're going to bike-shed it, I vote to add a new *intro* character
> instead of "m" and "s".
>
> my $foo = $bar =~ f/one/two/;

We don't want to lose our s/// roots, though.

For maximum clarity, I suggest U+017F:

http://www.fileformat.info/info/unicode/char/017f/index.htm

hdp.


rgs at consttype

Nov 26, 2009, 2:45 AM

Post #4 of 7 (376 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

2009/11/26 David Golden <xdaveg [at] gmail>:
>>> perhaps   s///f    should be spelled
>>>               m///
>
> If we're going to bike-shed it, I vote to add a new *intro* character
> instead of "m" and "s".
>
> my $foo = $bar =~ f/one/two/;

Both propositions have large parsing and compatibility problems.

First proposal: it will be difficult for the tokenizer to distinguish
between m// and m/// ; in the general case it will need too much
lookahead. (Especially considering the /x flag and arbitrary delimiters)

Second proposal: if we introduce a new lead, like f///, that means that
we define a new keyword : suddendly things like f() will fail to
compile, because perl will expect f()() constructs.

--
The hypothesis of a lone inventor - an infinite Leibniz laboring away darkly
and modestly - has been unanimously discounted. -- Borges


Tim.Bunce at pobox

Nov 26, 2009, 9:24 AM

Post #5 of 7 (370 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

On Thu, Nov 26, 2009 at 11:45:43AM +0100, Rafael Garcia-Suarez wrote:
>
> Second proposal: if we introduce a new lead, like f///, that means that
> we define a new keyword : suddendly things like f() will fail to
> compile, because perl will expect f()() constructs.

I thought the general "we can't add new keywords" problem had been
addressed some time ago (but I can't remember the details).

Tim.


ben at morrow

Nov 26, 2009, 9:51 AM

Post #6 of 7 (372 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

Quoth Tim.Bunce [at] pobox (Tim Bunce):
> On Thu, Nov 26, 2009 at 11:45:43AM +0100, Rafael Garcia-Suarez wrote:
> >
> > Second proposal: if we introduce a new lead, like f///, that means that
> > we define a new keyword : suddendly things like f() will fail to
> > compile, because perl will expect f()() constructs.
>
> I thought the general "we can't add new keywords" problem had been
> addressed some time ago (but I can't remember the details).

feature.pm. That's its sole purpose.

Ben


ikegami at adaelis

Nov 26, 2009, 10:02 AM

Post #7 of 7 (373 views)
Permalink
Re: m/// (was [PATCH] Functional substitution (s///f) ) [In reply to]

On Thu, Nov 26, 2009 at 5:45 AM, Rafael Garcia-Suarez <rgs [at] consttype>wrote:

> Second proposal: if we introduce a new lead, like f///, that means that
> we define a new keyword : suddendly things like f() will fail to
> compile, because perl will expect f()() constructs.
>

use feature, plus a "rarer" keyword than "f"?

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.