Skip Menu |
Report information
Id: 119317
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: rjbs <rjbs [at] cpan.org>
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Subject: [EXPERIMENT] smartmatch and given/when
Date: Thu, 15 Aug 2013 21:52:44 -0400
To: perlbug [...] perl.org
From: Ricardo Signes <rjbs [...] cpan.org>
Download (untitled) / with headers
text/plain 897b
Okay, the ~~/given/when feature, introduced in perl 5.10.0, has been discussed plenty already. Seriously, plenty. For one of the many threads, consider: http://www.nntp.perl.org/group/perl.perl5.porters/2012/08/msg191210.html Sprout did a bit of work on implementing things as discussed and this work then languished, mostly because I didn't realize he was waiting on a rely, and then because he was on hiatus. At present, it's still sort of languishing, mostly I think, because I need to reply. Steps to resolve this: * review the work currently done (sprout/smartpatch) * respond to it * figure out what remains undone * test that * decide whether it makes sense * establish final acceptance criteria * finish up (See also http://markmail.org/message/eplhjfyep6yigwtl ) I will try to get this moving again as much as I can so we can bring it to a conclusion. -- rjbs
Subject: Re: [perl #119317] [EXPERIMENT] smartmatch and given/when
Date: Thu, 15 Aug 2013 21:57:47 -0400
To: perl5-porters [...] perl.org
From: Ricardo Signes <perl.p5p [...] rjbs.manxome.org>
Download (untitled) / with headers
text/plain 304b
* Ricardo SIGNES <perlbug-followup@perl.org> [2013-08-15T21:53:06] Show quoted text
> Sprout did a bit of work on implementing things as discussed and this work
In chosing the phrase "a bit of work," I did not mean to make any claim about the effort involved. I apologize if I seemed to trivialize hard work! -- rjbs
Download signature.asc
application/pgp-signature 490b

Message body not shown because it is not plain text.

RT-Send-CC: perl5-porters [...] perl.org
On Thu Aug 15 18:53:06 2013, rjbs wrote: Show quoted text
> > Okay, the ~~/given/when feature, introduced in perl 5.10.0, has been > discussed > plenty already. Seriously, plenty. For one of the many threads, > consider: > > http://www.nntp.perl.org/group/perl.perl5.porters/2012/08/msg191210.html > > Sprout did a bit of work on implementing things as discussed and this > work then > languished, mostly because I didn't realize he was waiting on a rely, > and then > because he was on hiatus. At present, it's still sort of languishing, > mostly I > think, because I need to reply. > > Steps to resolve this: > > * review the work currently done (sprout/smartpatch) > * respond to it > * figure out what remains undone > * test that > * decide whether it makes sense > * establish final acceptance criteria > * finish up > > (See also http://markmail.org/message/eplhjfyep6yigwtl ) > > I will try to get this moving again as much as I can so we can bring > it to a > conclusion.
IIRC, the last two issues that had not been ironed out were • What the fallback should be: eq or fatal • How ‘break’ should behave: like ‘next’ (my preference) or buggy (your preference) OK, that last bit was tongue-in-cheek. However, you never gave a full explanation of how you want ‘break’ to behave. I was poking you with questions (does it apply to while(<>)?), and getting short answers that led me to believe you had not really thought it through. This is all from memory. I haven’t gone to look back at the archives. (I don’t have access to markmail.org, so I don’t know which message you refer to above.) Another note: Amidst the whirling threads about how smartmatch should behave, I pointed out that we already have a generic ‘matcher’ object in perl: the coderef. You thought that having something that accepts coderefs or regexps was a good idea. More recently I have thought about allowing qr//->($match_against_this). Regardless of smartmatch, that might be a good idea. What do you think? -- Father Chrysostomos
CC: Perl5 Porters Mailing List <perl5-porters [...] perl.org>
Subject: Re: [perl #119317] [EXPERIMENT] smartmatch and given/when
Date: Mon, 19 Aug 2013 00:43:03 -0300
To: Brian Fraser via RT <perlbug-followup [...] perl.org>
From: Brian Fraser <fraserbn [...] gmail.com>
Download (untitled) / with headers
text/plain 2.7k
On Sun, Aug 18, 2013 at 3:41 AM, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
Show quoted text
On Thu Aug 15 18:53:06 2013, rjbs wrote:
>
> Okay, the ~~/given/when feature, introduced in perl 5.10.0, has been
> discussed
> plenty already.  Seriously, plenty.  For one of the many threads,
> consider:
>
>   http://www.nntp.perl.org/group/perl.perl5.porters/2012/08/msg191210.html
>
> Sprout did a bit of work on implementing things as discussed and this
> work then
> languished, mostly because I didn't realize he was waiting on a rely,
> and then
> because he was on hiatus.  At present, it's still sort of languishing,
> mostly I
> think, because I need to reply.
>
> Steps to resolve this:
>
>   * review the work currently done (sprout/smartpatch)
>   * respond to it
>   * figure out what remains undone
>   * test that
>   * decide whether it makes sense
>   * establish final acceptance criteria
>   * finish up
>
> (See also http://markmail.org/message/eplhjfyep6yigwtl )
>
> I will try to get this moving again as much as I can so we can bring
> it to a
> conclusion.

IIRC, the last two issues that had not been ironed out were
• What the fallback should be: eq or fatal
• How ‘break’ should behave: like ‘next’ (my preference) or buggy (your
preference)

OK, that last bit was tongue-in-cheek.  However, you never gave a full
explanation of how you want ‘break’ to behave.  I was poking you with
questions (does it apply to while(<>)?), and getting short answers that
led me to believe you had not really thought it through.

This is all from memory.  I haven’t gone to look back at the archives.
(I don’t have access to markmail.org, so I don’t know which message you
refer to above.)

Another note: Amidst the whirling threads about how smartmatch should
behave, I pointed out that we already have a generic ‘matcher’ object in
perl: the coderef.  You thought that having something that accepts
coderefs or regexps was a good idea.  More recently I have thought about
allowing qr//->($match_against_this).  Regardless of smartmatch, that
might be a good idea.  What do you think?


You can already implement this without having to modify the core:

    package Regexp { use overload q[&{}] => sub { my ($re) = $_[0]; sub { $_[0] =~ $re  } }, fallback => 1 }
    say qr/f(oo)/->("foo")

So perhaps it should be tested on CPAN first. I don't see much use for it, but YMMV*; personally, I'd prefer something like this:

    sub Regexp::match { return $_[1] =~ $_[0] }
    say qr/f(oo)/->match("foo")

But I guess that's what autobox is for.


[*] For the curious, yes, I've spent an inordinate amount of time reading TV Tropes today.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org