Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> this was never about regex engines

Since you explicitly talked about filling the fields in an f string with already parsed regex objects instead of strings, it's hard to see what else you could mean. But even if I s/regex engine/DSL parsing engine in general/, I would like to see an actual example of a language or library where I can have a string like a Python f-string whose fields can be filled with some kind of parsed "engine" object instead of another string.

> Composing DSL programs by string concatenation is such a famous source of security bugs you see it in top-10 lists.

I don't see how composing DSL programs by filling in string fields with parsed "engine" objects is much better. I personally don't like regexes in general because I find them too hard to reason about unless they're extremely simple (and regexes that simple usually aren't necessary). I would rather try to write library functions (which might include functions that build other functions) in the same language as the rest of my program.



Yeah, sorry I didn't explain tagged template literals, just linked to an example.

You could make one called, say, rx for regex. Then

    rx`${a}|${b}`
would evaluate to exactly the same result as a tree constructor call like

    regex_or(a, b)
given corresponding definitions of rx and of regex_or. There's never any question of whether a and b are escaped right. So it brings the composability advantage of the library functions you prefer, to people who want to write these concrete-syntax regular expressions that started the whole thread.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: