It is "common knowledge" that source filters are bad and should not be used in production code.
When answering a a similar, but more specific question I couldn't find any good references that explain clearly why filters are bad and when they can be safely used. I think now is time to create one.
- Why are source filters bad?
- When is it OK to use a source filter?
Why source filters are bad:
- Nothing but perl can parse Perl. (Source filters are fragile.)
- When a source filter breaks pretty much anything can happen. (They can introduce subtle and very hard to find bugs.)
- Source filters can break tools that work with source code. (PPI, refactoring, static analysis, etc.)
- Source filters are mutually exclusive. (You can't use more than one at a time -- unless you're psychotic).
When they're okay:
- You're experimenting.
- You're writing throw-away code.
- Your name is Damian and you must be allowed to program in latin.
- You're programming in Perl 6.