procmail
[Top] [All Lists]

Re: Two variable assignments on one line?

1998-08-26 08:00:52
jari(_dot_)aalto(_at_)poboxes(_dot_)com writes:
|Tue 1998-08-25 Gregory Sutter <gsutter(_at_)pobox(_dot_)com> list.procmail
| 
| > Maintainability should be paramount. 
| 
| I have a case where, as an action for every recipe in a large set, I
| set a variable and call an includerc.  The includerc line never changes
| and I wanted to keep it compact and clear.  Here's an example, also
| showing Philip Guenther's Message-Id rule, which has been in demand
| lately:
| 
| # Phil Guenther's Message-Id: rule
| :0
| * ()^Message-Id:\/.*
| * ! ^Message-Id:[       ]*<[    ]*("([^"\]|\\.)*"|[-!#-'*+/-9=?A-Z^-~]+)\
|         ([      ]*\.[   ]*("([^"\]|\\.)*"|[-!#-'*+/-9=?A-Z^-~]+))*\
|         [       ]*(_at_)[    ]*\
|         (\[[    ]*([^][\]|\\.)*[        ]*\]|\
|          [-!#-'*+/-9=?A-Z^-~]+([        ]*\.[   ]*[-!#-'*+/-9=?A-Z^-~]+)*)\
|         [       ]*>
| { JFMATCH="$JFSEC: Bad Message-Id: $MATCH" INCLUDERC=$JFDIR/junkfilter.match
 }

Philip :-) Wouldn't you like to think in terms of abstraction, my eyes
hurt if I ever had to deal with maintenance tasks of this kind of code.
I would do:

In my original exposition of that regexp, I showed how I built it up
from the relevant syntax lines in rfc822.  Indeed, at your request I
then posted a variableful version with variables named after some of
those syntactical categories.  It's not my fault if someone chooses the
One Huge Regexp version.  Rather, I agree with them with the following
reasoning:

1) I'm not planning on "maintaining" that code, as the syntax for
   message-id will not, for practical reasons, ever change.

2) I some how doubt that anyone else will change that regexp more than
   trivially (e.g., negate it, make it start "^Resent-Message-ID:",
   change the line breaks).

3) If none of your other regexps use the categorical variables, and
   you're not changing the message-id regexp, then what's the point?
   The variablized version will be slower, and will clutter the
   environment of subprocesses.

So, the only reason I can see to break it up would be if you have other
uses for the subregexps.  I you don't, don't do it.  If you do, here's
a URL to my followup:

   http://www.xray.mpe.mpg.de/mailing-lists/procmail/1998-03/msg00375.html


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>