[Rd] Unbalanced parentheses printed by warnings() crash text editor

Martin Maechler maechler at stat.math.ethz.ch
Fri Aug 20 14:29:41 CEST 2004


>>>>> "PD" == Peter Dalgaard <p.dalgaard at biostat.ku.dk>
>>>>>     on 20 Aug 2004 12:01:39 +0200 writes:

    PD> Duncan Murdoch <murdoch at stats.uwo.ca> writes:
    >> >I could have sent this to the ESS or Xemacs devel list, but ESS & Xemacs'
    >> >attempt to find balanced parentheses accross many lines seems sensible,
    >> >and is needed with very long functions.
    >> 
    >> Yes, it's sensible to try, but it is a bug that they don't fail
    >> gracefully.

    PD> (Actually, it is not sensible; ESS should try harder to figure out
    PD> what is actually R code. Much as I love ESS, it is a persistent fly in
    PD> the ointment when the opening blurb comes up with "for" and "in" in
    PD> magenta.)

I'm chiming in, since I have been addressed explicitly here (for
whatever reason):

Yes, yes, and yes to Duncan's and Peter's notes:

- This should have gone to the ESS-help mailing list
- it's no bug in R and a bug in ESS/Xemacs (actually a bug in Xemacs combined
  with a missing feature in ESS).

Martin Maechler

For the sake of ESS-help, here's the original message as well:

>>>>> "Mayeul" == Mayeul KAUFFMANN <mayeul.kauffmann at tiscali.fr>
>>>>>     on Thu, 19 Aug 2004 23:32:51 +0200 writes:

    Mayeul> ... Hope it is the good place for this
    Mayeul> (I discuss the question of the right place below).

    Mayeul> Most of the time, warnings are more than 1000

[?? you probably mean something like '100', not '1000', right?]

    Mayeul> characters long and thus are truncated.  Most of the
    Mayeul> time, this generates printouts with unbalanced parentheses.

    Mayeul> Intelligent text editors which do parentheses
    Mayeul> highlighting get very confused with this.  After too
    Mayeul> many warnings, they give errors, and may even crash.

crashing *must* be a bug of the editor setup (ESS - XEmacs -
Windows), not of R.

    Mayeul> Specifically, I use ESS and XEmacs for Windows Users
    Mayeul> of R (by John Fox) which is advised to do at
    Mayeul> http://ess.r-project.org/ with a buffer for text
    Mayeul> editing and an inferior ESS (R) buffer.  (I
    Mayeul> downloaded the latest Xemacs and ESS a month ago).

    Mayeul> After too many warnings (with unbalanced
    Mayeul> parentheses), Xemacs swithes to an ESS-error buffer
    Mayeul> which says "error Nesting too deep for parser".  In
    Mayeul> some case, when back in R buffer, typing any letter
    Mayeul> switches back to the ESS-error Buffer.  In other
    Mayeul> case, it simply takes ages (until you kill Xemacs)
    Mayeul> or it crashes.  In most case, the R process is lost.

    Mayeul> I could have sent this to the ESS or Xemacs devel
    Mayeul> list, but ESS & Xemacs' attempt to find balanced
    Mayeul> parentheses accross many lines seems sensible, and
    Mayeul> is needed with very long functions.

    Mayeul> A workaround would be to change the function that print warnings.

    Mayeul> Instead of, for instance,
    Mayeul> "error message xxxxxxxxxx in: function.yyyyyy(zzzzzzzzz,zzzzzzz,   ..."

    Mayeul> It may print
    Mayeul> "error message xxxxxxxxxx in: function.yyyyyy(zzzzzzzzz,zzzzzzz,   ...)"

    Mayeul> The function should truncate the error message, find
    Mayeul> how many parenthesis and brackets are open in the
    Mayeul> remaining part, substract the number of closing
    Mayeul> parenthesis and brackets, and add that many
    Mayeul> parenthesis at the end.  (Xemacs parentheses
    Mayeul> highligher regards "(" and "[" as equivalent)


    Mayeul> Mayeul KAUFFMANN
    Mayeul> Univ. Pierre Mendes France
    Mayeul> Grenoble - France



More information about the R-devel mailing list