Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Critique on comment syntax and suggestions

From   "Mason, Bryce" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: RE: Critique on comment syntax and suggestions
Date   Fri, 28 Jan 2011 10:43:10 -0800

I disagree that this falls under a syntax error. Stata now has color coding and when a comment is initiated it turns the comment green. That is the intent. Until the comment is ended, it should remain green, regardless of the delimiter expected (EOL, semicolon, */, or otherwise).

The do-file editor already scans the text continuously as evidenced by colors changing and code folding, so I do not think it would be much trouble for it to "know" the defined delimiter and act appropriately. Room for improvement.


On Jan 28, 2011, at 10:33 AM, Steven Samuels wrote:



I've been bitten in the past by omitting semicolons. I now use
continuation characters, and reserve the semicolon to delimit single
commands, especially for graphs, that have many, often long, options.
I find such commands easier to read and modify if each option is on a
single line. If I use continuation characters in such commands, the
lines look messy unless I line the characters up. For me that's too
much work. As Nick said, it's personal taste.

Bryce, you are asking Stata's do-file editor to find syntax errors,
and I don't think that's its function.  After reading the second post
David referred to (it's by Joseph Coveney), I don't really see a bug.
Off topic, "Stata" is spelled "Stata." See the FAQ Section 8.2.


On Jan 28, 2011, at 12:51 PM, Nick Cox wrote:

Thanks for the reference.

On this point I think it mostly boils down to personal taste.

The history is simple: the original developers of Stata were highly
active and experienced C programmers before they ever invented Stata.
I suspect this detail was for their use when so inclined, and not just
for users outside the company. However, the publicly visible house
style of StataCorp is to use #delimit ; very sparingly. But that has
no implications for anyone else.

But if I follow Bryce correctly there is a small bug in the do-file
editor, which regardless of taste is an action point for StataCorp.


On Fri, Jan 28, 2011 at 5:38 PM, David Radwin <[email protected]<mailto:[email protected]>>

I was tripped up by the interaction of semicolon delimiters and
recently, too, as were others in the past, before the built-in
editor had
syntax highlighting:

But there is another solution: don't use semicolon delimiters, even
if you
are accustomed to using them in other software.

Nick Cox makes this point in "Suggestions on Stata programming style"
(Stata Journal 2005, vol 5, Number 4, pp. 560-566).

Mason, Bryce

Although not a question, thought this might be of interest as a

I was stymied by poor commenting practice but also by STATA's
color coding of comments. Consider the following:

# delimit ;
* This next line won't get processed because I forgot to put a
drop if criticalvar=1;

Unfortunately, STATA's do-file editor inappropriately colors the line
the drop command as if it will be processed, even though the
not applied to the comment line. It would be great if the do-file
knew that we were using a semicolon and made that whole section green
until it encountered a semicolon, but I do not see this being easily

We will be moving our standard commenting practice to /* and */ in
to avoid this issue.
*   For searches and help try:

*   For searches and help try:

Bryce Mason, Ph.D.
Director of Institutional Research
Loyola Marymount University
1 LMU Drive, Suite 4820
Los Angeles, CA 90045-2659
e: [email protected]<mailto:[email protected]>
w: (310) 258-8838
f: (310) 338-1841

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index