MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cell["\<\ ... \>", ... ; TextData[...]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114775] Re: Cell["\<\ ... \>", ... ; TextData[...]
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Thu, 16 Dec 2010 05:51:39 -0500 (EST)

Cell[_String] is equivalent to Cell[TextData[{_String}]] as far as the front end
is concerned.  The former is just an abbreviation of the latter syntax, which is
necessarily used when the contents are more complex (e.g., contain styles or
buttons).

The \<\> business dates back to a hoarier day (in my opinion) in the design of
strings in Mathematica.  Once upon a time, Mathematica had an odd interpretation
of newlines which I probably made more sense in the days of 80 character
terminal usage.  You'll have to forgive me...my memory is fuzzy here, and I
don't have an old Mathematica text to double-check this from my current
location...but I believe the issue was something like this...

"abc\
         d"

...with the newlines and spaces as shown, being equivalent to "abc d" (with just
the single space).  The \<\> business forced everything inside the string to
really be interpreted literally, with backslash at the end of a line meaning to
simply escape the newline, and do nothing special to leading spaces.  Since the
Mathematica notebook format generally wraps at about 70 characters, the
non-literal interpretation would have made the representation of more than 70
consecutive spaces difficult.

The modern Mathematica notebook format (introduced in 1996) was always made to
be interpreted properly as a Mathematica expression should you call Get[] on it
from the kernel.  So this syntax was standardized, and is still used today.
Now, the kernel simply ignores the \<\> delimiters as you can see below:

In[1]:== StringLength["\<x\>"]

Out[1]== 1


Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Wed, 15 Dec 2010 07:51:11 -0500 (EST), kj wrote:
>
>
> When I examine the source code of Mathematica notebooks, I often
> see Cell objects whose first argument is preceded by
>
> "\<\
>
> and followed by
>
> \
> \>"
>
> E.g.
>
> Cell["\<\
> Yet another undocumented item.\
> \>", "Text"...
>
> What do these delimiters mean?  And how do they differ from the
> TextData symbol?  (The latter is also undocumented, but at least
> I've seen "cameo appearances" of it in the documentation.)
>
> TIA!
>
> ~kj



  • Prev by Date: Re: how to plot nminimized result
  • Next by Date: Re: How to create a notebook outside of Mathematica?
  • Previous by thread: Re: Cell["\<\ ... \>", ... ; TextData[...]
  • Next by thread: NMinimize::nrnum: