Danielle H. Ferry
>
> > Thank you, Nick & Roger! I can see that Nick's & Roger's
> answers are
> > essentially the same. One more (macro) question: Why isn't
> > it necessary in
> > Roger's solution to put a space between _fvalcur_ and
> > _:label (mpg)_ ?
>
> ... because Stata's parser is splitting the command line
> into tokens. It is crawling along character
> by character:
>
> 1. following its own rules on legal names, the
> colon cannot be part of the macro name;
>
> 2. so the "r" of "fvalcur" must be
> the last character of that name
> and the ":" must be something else;
>
> and
>
> 3. a colon is legal at that point.
To expand a little on this: The manuals sometimes lie a
little and blur the difference between syntax and style.
Revisiting the example,
local fvalcur:label (factor) `l'
There _must_ be a space between -local- and -fvalcur- for
this to work.
localfvalcur
would be legal _only_ to the extent that
there was a program with that name. (I
suppose it is _legal_ even if there isn't,
but it won't work.)
Perhaps surprisingly, all the other spaces are
_optional_. You could write
local fvalcur:label(factor)`l'
and this will work, because there is _just_ enough
information here for the parser to change its
mind at the right moments and to treat this as equivalent
to what would often be written like
local fvalcur: label (factor) `l'
The extra issues arising here are readability and compactness.
For example, I favour putting spaces around almost all operators
and at least after most separators, if not before.
Readability shouldn't need much of a puff. For example,
programs vary enormously in how difficult they are to
read, and thus to understand, to debug, to correct and to modify.
On the other hand, compactness is also a virtue, and very
long lines in programs can be, if anything, even more
difficult to grasp.
. ssc desc stylerules
brings up one set of "rules", which also tries to explain its
own limitations. I'll emphasise that it's just one person's
jottings, except that it's also an anthropologist's attempt to
epitomise (some of) Stata developers' house style.
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/