On Thu, 17 Jul 2008, Gordon Hughes wrote:
The difficulty with the use of pointers rather than $ accessors is
really one
of how to provide a single package which implements the basic procedure for
the novice user while giving the expert user the ability to recover
additional results. By adding the requirement to define additional variables
and provide the relevant pointers the function becomes less easy to use for
someone who just wants to run a simple estimation and has no requirement for
anything beyond the basic printed output.
Point taken. I've just committed to CVS a little modification that may
help in these cases; Allin, feel free to revert it if there's anything
wrong with it, but I tested it a little and there seem to be no ill side
effects (famous last words). Basically, the keyword "null" is now a valid
value for pointers, and can be specified as a default value.
The following example script, which obviously will only run on a fresh CVS
build, should clarify what I mean:
<script>
function foo(series x, matrix *q[null], series *e[null])
m = mean(x)
if !isnull(q)
q = quantile(x,0.1) | quantile(x,0.9)
endif
if !isnull(e)
e = x - m
endif
return scalar m
end function
nulldata 20
series x = normal()
scalar m0 = foo(x)
matrix q
m1 = foo(x, &q)
series e
m2 = foo(x, null, &e)
print m0
print m1
print m2
print q
summary x e
</script>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti