perlsource-filter

What concerns should I have if I use Smart::Comments in development code?


I understand that Smart::Comments should not be used in production code, since it is a source filter.

However, I have been using Smart::Comments in my development code and then commenting out the "use" line before sending the code to production.

Given that I'm going to use it in my development code, what I should specifically be concerned about? I've searched the Internet and not found any reasons that I should be worried except that source filters are "a bad idea" or "evil" or that they should never be used in production code.

UPDATE: I'm now using a key binding in vim to implement Sinan Ünür's approach:

map <Leader>c <Esc>:!perl -MSmart::Comments %<CR>

Solution

  • Source filters are bad problematic because they use an imperfect parser to rewrite your code. Everything works great, as long as the filter manages the code you feed it.

    The moment you add something that breaks the filter, the whole system self-destructs and you get bizarre bugs.

    Source filters also confuse the debugger, which can be a problem--if you use the debugger.