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

From |
Maarten buis <maartenbuis@yahoo.co.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Stata comments |

Date |
Thu, 1 May 2008 21:26:38 +0100 (BST) |

Interesting puzzles, and I don't know the answer. On a practical level though, the comments are meant to be read by humans, so I would want to make sure that in my code it visually clear what part is a comment and what not. A habbit like that should avoid any ambiguities. At least, I cannot remember an instance where I have been bitten by these things. -- Maarten --- Sergiy Radyakin <serjradyakin@gmail.com> wrote: > Thank you Maarten, > > this is exactly the point: does the end-of-the-line as it is > understood by #delimit agree with the end of the line as it is > understood by comments? > > I have 2 possible interpretations of "line". > 1. Line in the text file (as it is understood by a text editor, > showing current line number and cursor position in the line) > 2. Line of code (which can occupy more than one text-line if the > delimiter is set to ";") > > > Here are my doubts: > > A. If the manual really means "line" as defined by 1, than the > following code must yell "Hello one" and "Hello two", but it does > not: > > #delimit ; > *include "something" > // comment > di "Hello one"; > di "Hello two"; > // end of file > > I think it must yell two times, because the commands are unaffected > by > commentaries in the other text lines if definition 1 is true. > > B. If the manual really means "line" as defined by 2, than the > following code must yell only "Hello two", but it does not: > > #delimit ; > // comment > di "Hello one"; > di "Hello two"; > // end of file > > I think it must yell only once, since everything from "//" till ";" > must be a comment, and only di "Hello two"; must be executed. > > It seems that "*" and "//" are somehow different. I have an external > program, that modifies .ado files to it's needs, and it get's > confused > in these situations. So any advice would be very welcomed. > > I am also experiencing difficulties with understanding priorities > among the commentaries. > > Consider the following code: > > #delimit ; > /*; > /*; > */; > di "test"; > */; > di "test2"; > // end of file > > If we run this code, only "test2" is output, because /* */ comments > may be "shelled", so that if the comment is opened several times with > "/*" Stata will require exactly as many "*/" to cancel the comment. > > It seems that "//" has priority and cancels "/*" and "*/": > > #delimit ; > // /*; > /*; > */; > di "test"; > // */; > di "test2"; > // end of file > > (both "test" and "test2" are written). > > However, not always??? > #delimit ; > // /*; > /*; > // */; > di "test"; > // */; > di "test2"; > // end of file > > (If the above logic is true, than the comment is open in line 3 spans > until the end of the file) > > In general, has anybody done parsing of a Stata .do / .ado file and > could share a boolean function (in any language), which can answer > whether a symbol (i,j) in the file is a part of a comment or not? (i > - > is the line number, j - position in line). If this is at all > possible? > > Thank you, Sergiy Radyakin > > PS: I am working with Stata for Windows 9.2 if the version matters. > > > On 5/1/08, Maarten buis <maartenbuis@yahoo.co.uk> wrote: > > --- Sergiy Radyakin <serjradyakin@gmail.com> wrote: > > > I have a question regarding the use of comments in Stata > programs. > > > > > > The two possibilities to comment out a line of code are to put a > "*" > > > or "//" in the beginning of a line. > > > > > > The manual (e.g. online here: > http://www.stata.com/help.cgi?comments) > > > says: > > > > > > " * indicates that the line is to be ignored." > > > and > > > "// indicates that the rest of the line is to be ignored." > > > > > > Both definitions are using the concept of a "line". I would like > to > > > double-check, what is really meant by "line" in this context? > > > > that is determined by the -#delimit- command, see: -help #delimit-, > but > > by default a line ends with a carriage return. > > > > Hope this helps, > > Maarten > > > > ----------------------------------------- > > Maarten L. Buis > > Department of Social Research Methodology > > Vrije Universiteit Amsterdam > > Boelelaan 1081 > > 1081 HV Amsterdam > > The Netherlands > > > > visiting address: > > Buitenveldertselaan 3 (Metropolitan), room Z434 > > > > +31 20 5986715 > > > > http://home.fsw.vu.nl/m.buis/ > > ----------------------------------------- > * > * 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/ > ----------------------------------------- Maarten L. Buis Department of Social Research Methodology Vrije Universiteit Amsterdam Boelelaan 1081 1081 HV Amsterdam The Netherlands visiting address: Buitenveldertselaan 3 (Metropolitan), room Z434 +31 20 5986715 http://home.fsw.vu.nl/m.buis/ ----------------------------------------- ___________________________________________________________ Yahoo! For Good. Give and get cool things for free, reduce waste and help our planet. Plus find hidden Yahoo! treasure http://green.yahoo.com/uk/earth-day/ * * 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/

**References**:**Re: st: Stata comments***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

- Prev by Date:
**RE: st: Deleting Characters of a Var Name by index Number** - Next by Date:
**st: RE: Re: RE: RE: Deleting Characters of a Var Name by index Number** - Previous by thread:
**Re: st: Stata comments** - Next by thread:
**Re: st: Stata comments** - Index(es):

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