El 22/06/15 a las 21:47, Sven Schreiber escribió:
Am 22.06.2015 um 19:18 schrieb Riccardo (Jack) Lucchetti:
...
> # with this, your original y is safe
> moo()
Safe yes, but of course at the cost of not getting any benefit at all (=
the return value) from the function. I call this throwing the baby out
with the bathwater. How on earth can this non-retrieval of the return
value be considered a solution to the overwriting problem below, if the
solution defeats the purpose in the first place???
Yes Sven, but this is the way in which all type of functions work, for
example,
<hansl>
function scalar a()
scalar b=2
return b
end function
nulldata 6
a()
</hansl>
the a() invocation does not save the result, or the same with a series.
<hansl>
function series y()
genr time
series y = time*2
return y
end function
nulldata 6
y()
</hansl>
if you don't assign a value to the new created object this is not saved.
Any function you create can be executed without assignement, then I
think this function is something "similar" to a hansl COMMAND, and can
also be executed by assigning to an object, and in this way it is
working as something similar to a native hansl FUNCTION.
*Plus*, it's inconsistent with the way the built-in functions work.
Allin defended this discrepancy and we can argue about whether it's
defensible, but thereby the inconsistency fact itself is undisputed.
No, I think
your first phrase should be "*Plus*, it's inconsistent with
the way the built-in COMMANDS work".
I think here are some misunderstanding of native commands and native
functions.
The problem may be that we have the same spelling for some commands and
functions. For example if you look at the "Gretl Command Reference" ( I
am looking at the pdf)
you will see 'diff', 'lags' etc in the list of COMMANDS and also in the
list of FUNCTIONS.
Anyway, after thinking a little about the subject, I would say that a
bundle is a much more consistent and safe way of returning different
objects (at least in question of namespaces). You may have a look at
some packages we have in the server that produce bundles. For example,
my Brown package is very simple and produces several series in a bundle.
The package may contain a bundle-print function (as Brown has) which
will produce a nice window with the results. From the bundle icon in
this window you can save the series contained in the bundle. Always,
even if the package does not contain a defined bundle-print function you
may call the function assigning it to a new bundle name:
bundle bbrown=Brown(Ct,0.7)
and then this does not destroy any series of your dataset. The series
are there in the bundle so (although there is not a bundle-print
function), you always can go to the session view and extract series
which are inside the bundle, without any problem with the series in the
current dataset, because gretl asks for the name of the new series to be
created.
Of course, if you execute the bundle without assignement
Brown(Ct,0.7)
everything is thrown away, in the same way as with the other different
objects.
I think an experienced hansl user (as myself ;-)) should always use
bundles to return several objects. Does it mean that we should deprecate
the use of lists as return value of a function? It may be, but not
necessarily. And may be also that we should deprecate all use of lists,
because probably all their functionality can be done via bundles and
strings. Lists were created a long time ago before the existence of
strings and bundles (Do they come from ESL, Allin?) and they were a
solution valid for a such a time. Now we should take into account that
they may be an object more easy to manage than bundles, for new hansl users.
--
Ignacio Díaz-Emparanza
Departamento de Economía Aplicada III (Econometría y Estadística)
Universidad del País Vasco - Euskalherriko Unibertsitatea, UPV/EHU
Tfno: (+34) 94 601 3732
http://www.ehu.eus/ea3