[lug] XEmacs quoting madness!

Tkil tkil at scrye.com
Mon Aug 20 16:01:58 MDT 2001


>>>>> "Walter" == Walter Pienciak <walter at frii.com> writes:

Walter> Anyway, I dunno if the nasty part refers to Perl regexes (no
Walter> argument here -- they can give me headaches to look at, though
Walter> they are pretty powerful) or the language's syntax flexibility
Walter> (feature or a bug, you decide) [...]

i was actually referring to how perl made the decision to have regexps
as "first-class" constructs; compare to the more "regular" languages,
which encode the regexps within strings, with the concomitant double
quoting that started this discussion.

the choice of which characters are "special" within regexps is largely
orthogonal to the question of integration into the larger language;
emacs treats "(", "|", and ")" as normal characters which must be
backslashed to become special; since they are then encoded as strings,
you have the double-quoting issue again.

perl made different choices about special characters, and this happens
to have a double benefit in this case.  in most of my searches, i want
to use parens and pipes as special characters, and perl happens to
agree with me there.  since i don't have to escape them to use them
the way i like, i don't have to worry about double-quoting.

perl goes further by having a parser that understands regexps as
something other than double-quoted strings (which is what they mostly
otherwise are parsed as, excepting constructs like "m''"!).  even if
you do have to escape or special-ize something within a perl regex,
the parser guesses what you're doing, and you only have to backwhack
it once.

either way, i tend to view it mostly as a tradeoff.  i don't like all
the decisions made in either case, and both have given me fits at
various times.  in the case of emacs, i end up with stuff that looks
like this:

      (while (re-search-forward 
              (concat "^\\\""           ; beginning of line + initial quote
                      "\\([^\\\"]+\\)"  ; software bit
                      "[\\\",]+"        ; intervening commas and quotes
                      "\\([^\\\"]+\\)"  ; description
                      ".*$")            ; rest of line.
              (point-max) t) ;
        (replace-match (concat "part=\\1\n"
                               "  description=\\2\n"))))))

on the flip side, my perl editor (xemacs + cperl) isn't as smart about
regex quoting as perl is, so odd quotes and parens tend to break the
syntax highlighting and automatic indentation.  i usually end up just
putting a backslash in front of the offending character, and accept
the minor loss in readability in return for the advantages the
syntax-senstive editor gives me.

t.



More information about the LUG mailing list