Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXPERIMENT] smartmatch and given/when #13173

Labels
experiment ticket tracking an active experiment

Comments

Copy link

Migrated from rt.perl.org#119317 (status was 'open')

Searchable as RT119317$

Copy link
Author

From @rjbs

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

Copy link
Author

From @rjbs

* Ricardo SIGNES <perlbug-followup@​perl.org> [2013-08-15T21​:53​:06]

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

Copy link
Author

The RT System itself - Status changed from 'new' to 'open'

Copy link
Author

From @cpansprout

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?

--

Father Chrysostomos

Copy link
Author

From @Hugmeir

On Sun, Aug 18, 2013 at 3​:41 AM, Father Chrysostomos via RT <
perlbug-followup@​perl.org> wrote​:

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.

@rjbs rjbs added experiment ticket tracking an active experiment and removed Severity Low labels Apr 30, 2021
tonycoz added a commit to tonycoz/perl5 that referenced this issue Jul 22, 2024
jkeenan pushed a commit to jkeenan/perl5 that referenced this issue Aug 16, 2024
rawleyfowler pushed a commit to rawleyfowler/perl5 that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experiment ticket tracking an active experiment
Projects
None yet
Development

No branches or pull requests

2 participants