On Wed, 29 May 2013, Sven Schreiber wrote:
Am 29.05.2013 18:09, schrieb Allin Cottrell:
> On Wed, 29 May 2013, Allin Cottrell wrote:
>
> I've now put a trivial but complete example at
>
http://users.wfu.edu/cottrell/pkg/
('setnote' still is a secret I guess -- although it vaguely rings a
bell, maybe it was discussed somewhere?)
It's mentioned in section 12.7 of the User's Guide. I guess
it's time to add it to the function reference.
> Note that the main function, olsbundle(), calls the
> bundle-print function to display its results. This is one way
> of doing things. An alternative would be to include in
> olsbundle() the special comment [...]
Ok, thanks, I will try that (soon) -- what I don't understand here,
though, is why the bundle needs to be passed in pointer form.
It's a matter of efficiency: there's no need to duplicate the
entire bundle when passing it as an argument to
bundle-printing (or bundle-plotting) functions. Using a
pointer just gives access to the bundle as it exists at the
caller level.
> ## no-print ##
>
> (see section 6 in
>
http://gretl.sourceforge.net/papers/addons.pdf ) This signals
> to gretl that the function does not print its own results, in
> which case gretl will take care of calling the package's
> bundle-print function. (We don't want both of these things to
> happen.)
Somehow my feeling is that it would be good to not have this new syntax.
Or maybe it's the "mis-use" of the comment characters. Maybe instead a
specially named argument instead?
(Example:
function bundle olsbundle (series y, list X, bool addon_no_print[1]) )
Fair point: the use of a special comment in this context is ad
hoc and potentially fragile. Another possibility would be to
make "no-print" a property of a packaged function that can be
set via the package's .spec file (and preferably also via the
function-packager GUI).
In a "real life" counterpart of olsbundle a standard idiom
would be to include a boolean parameter for printing or not in
the olsbundle() function -- hence giving a choice to the user
calling this function via script -- and to supply a wrapper
function (defined as "gui-main") which calls olsbundle() with
that flag set appropriately (presumably, with printing on). In
that case it would be the wrapper function that wants the
no-print flag.
Allin