Statalist The Stata Listserver


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

Re: st: graph combine and a graph named n


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: graph combine and a graph named n
Date   Wed, 04 Oct 2006 22:07:04 -0500

German Rodriguez <grodri@Princeton.EDU> finds that he cannot use 
-graph combine- with memory graphs that are named -n-.  German writes,

> This curious result, where graph combine doesn't recognize a memory
> graph named n, came up in some work and is easily reproduced
> [...]
>
> Stata will complain that "n is not a memory graph". This also
> happens if you try -graph combine n a-
>
> However, -graph display n- works fine, showing that the graph
> exists, and -graph describe n- gives all the details, starting with
> "n stored in memory".
>
> The problem happens only if the graph is called n; you can
> substitute any single-letter name other than n in the fragment
> above, for example the more logical b, and it will work fine.
>
> Obviously graph combine doesn't like graphs named n. What am I
> missing?

German is right, -graph combine- does not like graphs named -n-.  This buglet
will be fixed in a future update.  As German notes, the easy work around is to
not name graphs -n-.

The behaviour of the buglet, accepting some one character names while
eschewing others, is curious enough that some may be interested in the
technical reason.  The class code that supports -graph combine- was not
careful about what computer scientists call scope.  The class itself has a
member variable called -n- and the code did not take care to reference the
global graph named -n- rather than the local counter named -n-.  In computer
science parlance, taking a member variable in preference to a global variable
is called shadowing, and in the right hands it is a powerful feature.  In
Stata's class system, you just add .Global before your reference and you can
force scope to the global namespace (there goes another computer science
term).  The code behind -graph combine- just didn't do that.  It will in the
future.

 
-- Vince
   vwiggins@stata.com

*
*   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/



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