| Bill Allombert on Sat, 15 Jul 2017 11:48:00 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: fetch_user_var() doesn't behave as I expect |
On Fri, Jul 14, 2017 at 10:39:55PM +0000, S. Gilles wrote:
> Hi,
>
> I wanted the following program to print "b=b, c=c", but unfortunately
> it printed "b=b, c=a".
>
> #include <pari/pari.h>
>
> int main(void)
> {
> pari_init(512 * 1024, 0);
> GEN a = varlower("a", 1);
> GEN b = gsubst(a, varn(a), varlower("b", 1));
> GEN c = gsubst(a, fetch_user_var("a"), varlower("c", 1));
> pari_printf("b=%Ps, c=%Ps\n", b, c);
> return 0;
> }
>
> Based on the manual's description of fetch_user_var(), I think this
> might be a bug, but it is also quite probable that my understanding
> of fetch_user_var() is incorrect.
No, this is correct. Variables created using varlower and fetch_user_var
live in a different namespace.
In library mode, you should rather use fetch_var/delete_var rather than
varlower.
Cheers,
Bill.