git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] grep: introduce and use grep_and_expr()

From
Taylor Blau <me@ttaylorr.com>
Date
Jan 7, 2022, 19:33 UTC
Message-ID
<YdiVmgJYPzVrIYE1@nand.local>
In-Reply-To
<c573cc00-d5b3-9af1-a627-6c2462cae3be@web.de>
On Fri, Jan 07, 2022 at 01:57:17PM +0100, René Scharfe wrote:
Show 21 quoted lines
> Am 06.01.22 um 20:50 schrieb Taylor Blau:
> > René,
> >
> > Here are a couple of extra patches on top of your series which introduce
> > and use a new grep_and_expr() function.
> >
> > Like the final patch says, this isn't about reducing code duplication,
> > but rather about adding visual consistency with the other
> > `compile_pattern_xyz()` functions.
> >
> > Taylor Blau (2):
> >   grep: extract grep_binexp() from grep_or_expr()
>
> I considered extracting such a function as well.  I'd have called it
> grep_binary_expr(), though, to match the existing names.
>
> I decided against it because it can be misused by passing a non-binary
> kind to it.  (That's a weak objection, but the benefit of such a
> function was low already in my mind because it doesn't do much.)  You
> solve this by keeping grep_or_expr() and adding grep_and_expr(), which
> cannot be misused in this way -- OK.

That makes sense. If it's keeping you up at night, we could easily add a check to ensure that `kind` is one of GREP_NODE_OR or GREP_NODE_AND. But I think that any new code that looks like:

    grep_binexp(GREP_NODE_NOT, xyz, NULL);

would probably stick out like a sore thumb. So I doubt that such a check would buy us much practically speaking.

But I agree that this whole thing probably isn't worth the minimal effort required, since the couple of patches I posted on top are purely about cosmetics.

All of that is to say that I'd be happy to see these patches picked up, and I would also not be sad at all to see them left on the floor.

Thanks, Taylor

Previous: René ScharfeNext: René Scharfe
Message 12 of 13 in “grep: use grep_or_expr() in compile_pattern_or()”
  1. 1/2 grep: use grep_or_expr() in compile_pattern_or()René Scharfe, Jan 6, 2022
  2. 2/2 grep: use grep_not_expr() in compile_pattern_not()René Scharfe, Jan 6, 2022
  3. 0/2 grep: introduce and use grep_and_expr()Taylor Blau, Jan 6, 2022
  4. 1/2 grep: extract grep_binexp() from grep_or_expr()Taylor Blau, Jan 6, 2022
  5. 2/2 grep: use grep_and_expr() in compile_pattern_and()Taylor Blau, Jan 6, 2022
  6. Junio C HamanoJan 6, 2022
  7. Taylor BlauJan 6, 2022
  8. 0/2 grep: introduce and use grep_and_expr()Taylor Blau, Jan 6, 2022
  9. 1/2 grep: extract grep_binexp() from grep_or_expr()Taylor Blau, Jan 6, 2022
  10. 2/2 grep: use grep_and_expr() in compile_pattern_and()Taylor Blau, Jan 6, 2022
  11. René ScharfeJan 7, 2022
  12. Taylor BlauJan 7, 2022
  13. René ScharfeJan 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.