On Sat, 26 Jan 2013, Allin Cottrell wrote:
On Sat, 26 Jan 2013, Pietro Battiston wrote:
> I love Gretl's "foreign" code blocks capability, and would love even
> more the possibility of using Python in them, which was at some time
> suggested as easy to implement.
Yes, quite easy. In fact, so easy that Python support is now
in gretl CVS and the snapshots for Windows and OS X. Here's a
trivial example:
Just crossed my mind: the "foreign" construct has evolved incrementally
over time. In the beginning, we only had diplomatic contacts with R, which
have evolved over times to comprise exchange of matrices etc. Then came
other foreigners, such as Ox, Octave/Matlab, etc. As a consequence, the
issue of passing stuff back and forth was dealt with quite
unsystematically, according to what the state of gretl was back then.
Now that we have the bundle data type, we may want to spent some time
thinking about revisting a few ideas: just like hansl has bundles, R has
lists, Matlab has structures, Python has dictionaries. It'd be
inordinately cool to be able to do something like
<hansl>
capsule["foo"] = 3
capsule["bar"] = "WOW!"
capsule["baz"] = mnormal(20,4)
foreign language=Octave --import=capsule --export=chest
temp = capsule.foo + 1
chest.blip = temp
end foreign
scalar whatever = chest["blip"]
</hansl>
In other words, use the fact that most of our foreign correspondents also
have associative arrays to define the idea of a wrapper structure to deal
with the import/export problems. Ideally, this would have to be done in
RAM (shared memory, perhaps?), but I could live with temporary files.
What do you guys think?
-------------------------------------------------------
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
-------------------------------------------------------