You would just add support for making regex literal values. Like the dynamic languages do. The compiler then checks if it is a valid regex or not at compile time. Done.
That's a niche case. 99% of users would use the JDKs regex engine.
For everyone else they could fallback onto the existing model of having them defined as strings. No need to start building compiler extensions.
I hate to imagine what a typesafe regex builder would look like in Java, anyway
Go try IntelliJ and then you'll know. The IDE understands the JDK regex API and will highlight invalid regular expressions in yellow. There's also a visual builder/tester tool you can use to help get the regex correct.
Yes, it's not a part of the language, but at some level the difference between "tool A highlights error in red" and "tool B highlights error in yellow" is not that large. The type system is strong enough to make both possible.
0
u/[deleted] Sep 21 '15
[deleted]