[lug] XEmacs quoting madness!

Tkil tkil at scrye.com
Mon Aug 20 15:44:38 MDT 2001


>>>>> "Tkil" == tkil  <tkil at scrye.com> writes:

Tkil> just as an aside, this is a place where you really start
Tkil> noticing the tradeoffs between regular, consistent,
Tkil> easy-to-parse languages (like lisp, python, tcl) and nasty,
Tkil> irregular, special-case-all-over-the- place languages (like
Tkil> perl).

apparently i didn't include enough smilies.  i thought enough people
know i am a perl geek, and thus my comment was ironic (or close to it).

the point i was driving at is a bit more abstract: should we force the
programmer to be closer to the machine (which makes for languages that
are easier for the computer to parse) or should we make allowances for
the programmer (which makes the languages harder for the computer to
parse).

both Tom and Walter make good points.  perl goes out of its way to
give the programmer flexibility in quoting, at the cost of being very
hard to parse correctly.  emacs goes the other way: by making
everything consistent and (relatively) simple to parse, you make the
programmer work a bit harder, but you gain power by being able to
manipulate the code as data.  this distinction bleeds over to context-
sensitive editors trying to indent or do syntax highlighting
correctly; it's much easier to write a pretty printer for lisp than
for perl...

it's a tradeoff, and the wide range of languages shows that there's no
one right answer.

it's particularly touchy with regular expressions embedded within
other languages (be it emacs-lisp or perl).  regexps are essentially
a little language with its own quoting rules.  when we put this little
language within a larger one, we have to deal with the containing
language's quoting rules as well.

the fact that regexps have dialects (grep, egrep, emacs, perl, etc)
just makes things more interesting.  Tom's points about the decisions
made by the different regex packages about what should be quoted is a
good example of the things that change among these dialects.  Jeffrey
Friedl's excellent book _Mastering Regular Expressions_ (O'Reilly)
does a fantastic job at discussing all of these issues.

so, in short, my comment about "special cases all over the place" was
not meant to be particularly negative; rather, it was just high-
lighting a trade-off that happened to be exposed by the discussion at
hand.

t.




More information about the LUG mailing list