Bookmark and Share

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


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

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


From   Steven Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Critique on comment syntax and suggestions
Date   Fri, 28 Jan 2011 13:33:32 -0500

--


--


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.

Steve

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.

Nick

On Fri, Jan 28, 2011 at 5:38 PM, David Radwin <dradwin@mprinc.com> wrote:
Bryce,

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

http://www.stata.com/statalist/archive/2008-11/msg01338.html
http://www.stata.com/statalist/archive/2008-09/msg01271.html

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).
http://www.stata-journal.com/sjpdf.html?articlenum=pr0018

Mason, Bryce

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

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

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

Unfortunately, STATA's do-file editor inappropriately colors the line
with
the drop command as if it will be processed, even though the delimiter
was
not applied to the comment line. It would be great if the do-file editor
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
implemented.

We will be moving our standard commenting practice to /* and */ in order
to avoid this issue.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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