On Tue, 7 May 2013, Allin Cottrell wrote:
 2) We provide a built-in function (or maybe eventually a
 command) that produces a plot from such a bundle: it checks
 for the creator of the bundle and hands off to the appropriate
 specialized plotting function.
 Right now this is (partially) implemented for the irf()
 function. Until now this function has returned a matrix, but
 in CVS it returns a bundle which contains the matrix along
 with the additional info needed for the plot (e.g. the names
 of the target and shock variables and the "alpha" for the
 confidence interval, if any).
 Isn't this backward incompatible? Actually, no. You can still
 assign from the irf() function to a matrix. That's because
 I've added a special bundle key: if you add a matrix to a
 bundle under the name "payload_matrix", then the following
 sort of thing (a "cast" from bundle to matrix) will work:
 <hansl>
 bundle b
 b["payload_matrix"] = I(3)
 b["otherthing"] = "hello"
 matrix m = b
 </hansl>
 Here's an example of the whole deal:
 <hansl>
 open data9-7
 var 4 UNEMP PRIME
 # assign from irf() to bundle
 bundle b = irf(1, 2, 0.2)
 bplot(b, "display")
 # we can still assign from irf() to matrix
 matrix m = irf(1, 2, 0.2)
 m
 </hansl> 
This is all very clever and has so much potential that I'm beginning to 
think that we should document this (and its generalisations like corrgm) 
in a separate chapter of the manual about bundles and what they can do for 
you.
However, there is an element of backward incompatibility which, I'm 
afraid, will be difficult to get rid of completely: suppose you do 
something like
<hansl>
list X = <whatever>
var 2 X
matrix Selected_IRFS = {}
loop foreach i 2 4 5
     Selected_IRFS ~= irf(3,i)
end loop
</hansl>
now you get an error, because you can't concatenate a matrix to a bundle. 
Of course, there are several ways around this; for example:
<hansl>
loop foreach i 2 4 5
     matrix tmp = irf(3,i)
     Selected_IRFS ~= tmp
end loop
</hansl>
or
<hansl>
loop foreach i 2 4 5
     bundle tmp = irf(3,i)
     Selected_IRFS ~= tmp.payload_matrix
end loop
</hansl>
or other equivalents. It would be cool if we could do
<hansl>
loop foreach i 2 4 5
     Selected_IRFS ~= irf(3,i).payload_matrix
end loop
</hansl>
but we can't at the moment.
-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)
   Università Politecnica delle Marche
   (formerly known as Università di Ancona)
   r.lucchetti(a)univpm.it
   
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------