[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: #delimit ; and // [was: undocumented command *]

From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   st: #delimit ; and // [was: undocumented command *]
Date   Sat, 27 Sep 2008 13:11:18 +0900

Sergiy Radyakin wrote (excerpted):

however Stata fails in the files with ; used as the line-terminator
and // in the first position in the line. So IMHO this is more
important to fix, then forbid using * as a comment marker.


Did you mean, "except when it's in the first position in the line", as in
example (1) below?  Where it would seem to cause inconsistent behavior is in
example (2) below, where the semicolon follows the // comment that is placed
between the end of the command and the end of the line.  The semicolon is
ignored in that case.

Nevertheless, I not so sure that what you refer to is so much a bug needing
fixing as a misunderstanding of what -delimit- does, and of the difference
between a command end and a line terminator.

The documentation for -delimit- states that marks the semicolon or carriage
return as the end of a _command_, and not a _line_.  Whereas, the
documentation for comments states, "// indicates that the rest of the _line_
is to be ignored." [Emphasis added.]

The distinction has a difference, although it might seem subtle.  It can be
illustrated below.  Example (1) is where the comment is in the first
position of the line.  It seems to behave as you want.  But notice the
">" line-continuation marker at the beginning of the next line.  This
indicates that semicolon (1) was actually ignored, and so is not any
exception:  its behavior there is consistent with its behavior in all of the
other examples [(2) through (4)] in the illustration, and is consistent with
the documentation distinguishing between line terminators and command

Example (3) shows that the _line_ termination is what's important to the
comment marker ("the rest of the _line_ is to be ignored") and not the
command delimiter:  despite absence of a semicolon in (3) when the command
delimiter is set as a semicolon, the following _line_ is executed and is not
commented out.  So, the _line_ terminator terminates a // comment, not the
command delimiter.  Again, consistent with the other examples and with the

Example (4) essentially shows the same phenomenon.  The command isn't
executed until it's ended and it's not ended until Stata sees the _command_
delimiter (not a line terminator), which in the case of (4) won't be seen
until the // comment is terminated with a _line_ ending.

The difficulty might arise because in the default case, the command
delimiter and line terminator happen to coincide, and so the expectation is
that the -delimit- command ought to change both together.

Joseph Coveney

. version 10.1

. clear *

. set more off

. #delimit ;
delimiter now ;
. // This will display it; (1)
display in smcl as result "It " as text "<- here";
It <- here

. capture noisily describe // No dataset; (2)
display in smcl "Nothing in memory";
in range not allowed

. describe ;

Contains data
 obs:             0
vars:             0
size:             0 (100.0% of memory free)
Sorted by:

.  // No dataset (3)
display in smcl "Nothing in memory";
Nothing in memory

. describe   // No dataset (4)
Contains data
 obs:             0
vars:             0
size:             0 (100.0% of memory free)
Sorted by:

. display in smcl "Nothing in memory";
Nothing in memory

. exit;

end of do-file

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index