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]

st: Wishlist for Stata 13


From   Clyde B Schechter <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Wishlist for Stata 13
Date   Thu, 10 Jan 2013 15:53:12 +0000

I wish the behavior of local macros were changed so that referencing a macro that has never been defined is an error, rather than treating it as an empty string.  I with I had a dollar for every time I have made a typo in a macro name.  (I haven't actually studied it, but I have the impression that local macro names are higher risk for typos because you have to displace your fingers from the home keys to reach the ` key.)  If you are lucky, the mistyped macro's being interpreted as an empty string will lead to a syntax error, as for example when it is being used to specify a varlist in a command for which varlist is not optional.

But often enough, the empty string leaves you with something that is legal, but wrong.  A good example:

by `farname1' `varname2' sort: .....[whatever]

will lead to perfectly legal syntax if `farname1' is a typo for `varname1' and is undefined.  But it leads to results other than intended.  If you're lucky the mistake will be immediately obvious in the results.  But sometimes you don't find out until several do-files later when results based on that start to look whacky.

Most programming languages enforce the principle that you cannot reference a term that you have not declared or defined (unless it is a language keyword), so the compiler or interpreter protects you from what is likely to be an error.  Yes, it means you have to do a little extra typing to define everything before using it.  But, to me at least, it's worth the effort to have that protection.  [Stata takes the protective approach in many other contexts, like not letting you overwrite your data set without explicitly saying so.]  Of course, all of us try to be careful in our work.  But, at least in my field of public health, it is generally recognized that a system that relies on human vigilance to work correctly is a system designed to fail.

Now, there are many Stata users who like not being forced to define a macro before using it; current default behavior works well for them.  So let's make it an option that the user can set to allow or disallow references to undefined macros.  And since there are probably a lot of ado files out there that rely on undefined macros' being legal empty strings, it probably should be automatically over-ridden when the code was written under an earlier version.

By the way, given that Stata 12 came out about a year and a half ago, I would guess that release of Stata 13 is about 6 months away.  I would also guess that the features of Stata 13 were decided a while ago and are already frozen.  So aren't we really talking about a wishlist for Stata 14?

Clyde Schechter
Dept. of Family & Social Medicine
Albert Einstein College of Medicine
Bronx, NY, USA



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


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