From bill at insightful.com  Tue Sep 26 19:12:22 2006
From: bill at insightful.com (Bill Dunlap)
Date: Tue, 26 Sep 2006 10:12:22 -0700 (PDT)
Subject: [Rd] sprintf behavior (PR#9250)
In-Reply-To: <20060925094613.B5FB64C91E@slim.kubism.ku.dk>
References: <20060925094613.B5FB64C91E@slim.kubism.ku.dk>
Message-ID: <Pine.GSO.4.56.0609260959290.2640@durian.statsci.com>

On Mon, 25 Sep 2006 ripley at stats.ox.ac.uk wrote:

> On Mon, 25 Sep 2006, michael.bauer at lo-res.org wrote:
> ...
> > sprintf("\p") doesn't show the backslash, this occurs with all strings that
> > start with certain letters. There is however no explanation to this behavior.
>
> There is: see ?Quote (and C behaves in the same way).
>
> > And there seems to be no way to get a guaranteed backslash in sprintf.
>
> "\\", see the FAQ 7.8 for example.

Splus's parser emits a warning when it sees a backslash
outside of the recognized backslash sequence.  E.g.,

  > nchar("\Backslashed?")
  [1] 12
  Warning messages:
    The initial backslash is ignored in \B -- not a recognized escape sequence.
          Use \\ to make a backslash

You might want to add that warning to R's parser.  I've
seen the error in several R packages.  E.g.,

  bayesmix/R/JAGScontrol.R:  text[4] <- "-inits.R\"\n\initialize\n"
  SciViews/svDialogs/R/fixedDlg.wxPython.R:        if (length(grep("[\.]", basename(res))) == 0)

The warning is mostly emitted when the error is benign, but it
might help get people to think about what they are typing.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."




[Rd] sprintf behavior (PR#9250)
Bill Dunlap