I suppose that what -c_local- does can be also done using -return- (plus
some copying of values, if desired). Perhaps -c_local- was around before
-return- was introduced.
This discussion reminds me of something I had experimented with recently. I
have written a lot of code with commands that appended a local:
local mystuff "`mystuff' other_stuff"
and I was doing that repeatedly, incrementally appending more and more
additional text onto mystuff. So I wondered whether this could be
programmed. I did not succeed at the time, but just now I realized what I
needed to do: the name of the local as well as the contents need to be
passed separately. Here is the code:
program def append_local
syntax , name(string) contents(string) newstuff(string)
c_local `name' "`contents' `newstuff'"
end
This is a bit unwieldy, and requires that you use it in a particular
way. So it's not worthwhile.
I think that Statacorp might consider making a new (built-in) command to do
this. It would go like ...
append_local localname "stuff_to_be_appended"
Thus, it would work just like -local-, but would append rather than
replace. (Is there already something like that -- that I am ignorant of?)
(I might add that such a command might be coded so as to put the appended
text right at the end, avoiding the re-evaluation and copying of the entire
expression as in
-local mystuff "`mystuff' other_stuff"-,
which can become very inefficient as the length of `mystuff' grows.)
-- David
David Kantor
Institute for Policy Studies
Johns Hopkins University [email protected]
410-516-5404