On Thu, 9 Feb 2017, Sven Schreiber wrote:
I am trying to become a forward-looking/rational-expectations/precog
bug
reporter... Seriously, here is a worry that is inspired from a trick that
Oleh used in one of his scripts with a 'foreign' block, but that hasn't
actually produced any errors in real life, at least for me.
AFAICS gretl currently applies string substitution with @-tagged unquoted
strings everywhere in the script. So a defined string s="be" can be injected
somewhere by writing @s. This feature can be used to transfer some string
values from the gretl environment to the 'foreign' environment.
However, this might become a problem when the @-character has another
syntactic meaning in the foreign language. For example in Python it starts a
so-called decorator.
Theoretical example without practical meaning:
<hansl>
string p = "heyho"
foreign language=Python
@property
def mypyfunc(...): ...
end foreign
</hansl>
The way I see it, gretl would turn the decorator line "@property" into
"heyhoroperty" which of course breaks the Python code.
If that assessment is correct, not sure what the best solution would be. As I
said, the behavior has been used intentionally by some.
Yes, point taken: our string substitution mechanism could in
principle mess up a "foreign" block.
Over the past year or so we've tried to provide alternatives to
string substitution where possible (e.g. the "setopt" command and
the the genseries() function) but these don't apply to foreign code.
One possibility would just be to skip string substitution inside
foreign blocks. What effect was Oleh achieving by this means?
Allin