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

It's kind of a cool feature. I like it.


Is it? I can't think of a non-contrived case where this would actually be useful.

And in any case where it would be useful, it seems like a better way to optimize would just be to refactor the regex out into a constant.


The context is that this is a feature cribbed straight from perl, where where it's passed down from perl 4/pre-5.6, where compiled regexen weren't first-class values. Pretty much every use of it this century is a mistake.


Actually, I have a way this would work well. If you’re interpolating a value that comes from configuration and wouldn’t change.

Example: /admin@#{Rails.config.x.domain}/io

But you’re right that a constant would be a lot more clear. “o” is a footgun.


An HTTP application server matching routes based on runtime configiuration (domains and whatnot) is not really that niche or contrived? Loads of other situations where input not changing during the thread/process lifecycle is part of a set of hot regexes large enough that explicitly compiling each is not a great experience.

I, for one, appreciate /o.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: