Author ncoghlan
Recipients hynek, loewis, lukasz.langa, ncoghlan, rhettinger, serhiy.storchaka
Date 2013-08-04.12:09:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
(Updated the issue title to reflect the currently proposed name and location for the functionality)

While I'm a fan of explicit iteration as well ("inside every reduce is a loop trying to get out"), I think the fact Martin's explicit loop is buggy (it will never match re2 as it always bails on the first iteration) helps make the case for coalesce. The correct explicit loop looks something like this:

    for r in (re1, re2):
        m = r.match('abc')
        if m is None:
        if r is re1:
        elif r is re2:
        break # Matched something
        print('No match')

(Or the equivalent that indents the loop body further and avoids the continue statement)

The coalesce version has a definite advantage in not needing a loop else clause to handle the "nothing matched" case:

    m = coalesce(regexp.match('abc') for regexp in [re1, re2])
    if m is None:
        print('no match!')
    elif is re1:
    elif is re2:
Date User Action Args
2013-08-04 12:09:45ncoghlansetrecipients: + ncoghlan, loewis, rhettinger, lukasz.langa, hynek, serhiy.storchaka
2013-08-04 12:09:45ncoghlansetmessageid: <>
2013-08-04 12:09:45ncoghlanlinkissue18652 messages
2013-08-04 12:09:45ncoghlancreate