Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: what is c_local?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: what is c_local?
Date   Fri, 12 Dec 2003 14:36:15 -0000

R. Allan Reese

> On Fri, 12 Dec 2003 13:25:42 -0000 Nick Cox <n.j.cox@durham.ac.uk>
> wrote:
> > Sometimes, it is nice to be able to
> > have a way round the rule and to have
> > a way of passing information back
> > to a calling program. (There are of course
> > other ways of doing this, not least globals.)
> >
> > What the -c_local- does is carry out
> > a macro definition in the calling program's
> > space. So the -display- will show 2.
> >
> > Warning: this is dangerous unless you really understand it.
>
> As described, it looks not only dangerous but pointless
> what happens
> if pest is called from another routine without a defined kardos?
> c_local looks "nowt nor summit".  It looks similar to Fortran's
> block equivalence and might have a marginal efficiency gain at
> run-time, but such effects should be achieved by passing parameters
> and returning results.

It's immaterial what's going on in the calling routine. That's
a consequence of the way local macros can just spring into existence.

program Buda
	...
	Pest
	di `kardos'
end

program Pest
	c_local kardos = 2
end

is fine, syntactically.

I am not up on programming dogmata; I've merely
found this very useful in practice. What is more, you
can pass parameters at the same time.

If it offends purists, and there is clearly an
argument against it (namely, "local" should mean
precisely that), it is entirely avoidable.

P.S. This is an international list, so I'll
explain for anyone needing it that Allan is lapsing into
Yorkshire, or more loosely Northern English, dialect.
"Nowt" means nothing and "summat" [sic] means "something".

Nick
n.j.cox@durham.ac.uk

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