Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: What are greedy and lazy matching in Perl?

by AnomalousMonk (Archbishop)
on Jul 30, 2015 at 09:52 UTC ( [id://1136833]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What are greedy and lazy matching in Perl?
in thread What is greedy and lazy Matching in perl

... if “lazy” is taken in its more general sense of “doing less work,” then ... frugal quantifiers do less work — and are in that sense “lazier” ...

But the first definition of the first citation of lazy given here suggests that rather than just passively happening to do less, "lazy" actively avoids effort: "Disinclined to action or exertion; averse to labor; ...; shirking work." This seems to me to capture the essence of the behavior of lazy quantification.

I can be happy with frugal, but I'm too lazy to type the extra characters. Non-greedy it a bit too Newspeak for me.


Give a man a fish:  <%-(-(-(-<

Replies are listed 'Best First'.
Re^4: What are greedy and lazy matching in Perl?
by BrowserUk (Patriarch) on Jul 30, 2015 at 10:11 UTC
    This seems to me to capture the essence of the behavior of lazy quantification.

    The general usage of 'lazy' in the context of programming is: deferred or on-demand; with the complementary term being 'eager'.

    I think that overloading lazy to mean non-greedy for this unique usage, just creates the potential for confusion and unreal expectations.


    Anyone got any experience of this phone's predecessor?

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
    I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
      ... the context ...

      But the context is a discussion of regex quantification, and what is the meaning of deferred or on-demand quantification?

      I will make my last-ditch stand upon an appeal to authority: The Book* by Friedl, which uses "lazy" as the primary term for this quantification mode. And there you have it: Friedl said it; I believe it; that settles it!

      * At least, the second edition of The Book. For some reason, I couldn't dig out my copy of the first edition, but I'm sure it uses the same terminology. I never bought the third edition. While preferring the term lazy, Friedl also acknowledges the terms "minimal matching", "non-greedy" and "ungreedy". I think I would use maximal/minimal matching in full-blown pedant mode (it is completely unambiguous WRT, e.g., deferred/on-demand/eager evaluation), but too cumbersome for everyday use; greedy/lazy for me. Ungreedy is just more Newspeak and so not to my taste.


      Give a man a fish:  <%-(-(-(-<

Re^4: What are greedy and lazy matching in Perl?
by Anonymous Monk on Jul 30, 2015 at 10:59 UTC
    most, least

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136833]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-20 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found