Charles Greathouse on Tue, 23 Feb 2010 06:10:37 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Getting the variable number of a lexical local variable


I see, thanks for the explanation.  So it's not possible to know what
variable number is used; maybe I should just change the format to
sumformal(1, n, x^3 + 3)
rather than
sumformal(x=1, n, x^3 + 3)
since I don't want to make users think they can control what variable is used.

But wait:
x=10;y=100;for(x=1,2,print(x^2*y))
and
x=10;y=100;for(y=1,2,print(x^2*y))
give different results.  How can they tell?

Charles Greathouse
Analyst/Programmer
Case Western Reserve University

On Mon, Feb 22, 2010 at 3:20 PM, Bill Allombert
<Bill.Allombert@math.u-bordeaux1.fr> wrote:
> On Mon, Feb 22, 2010 at 01:11:10PM -0500, Charles Greathouse wrote:
>> > The prototype code V is for functions that use the code E or I.
>> > Such local variables are not formal variables and does not have a
>> > formal variable number (but they have a lexical variable number).
>>
>> I guess what I was trying to find was the lexical variable number,
>> then.  I do want to use a V prototype code so that a user (in GP) can
>> type
>> sumformal(y=1, n, x*y^3 + y)
>> and I can pull the relevant variable out of the polynomial.
>
> If you use V, then you have to use the code E, and then you lose access
> to the polynomial. Instead you get a function that gives the values of
> the polynomial.  So unfortunately, you have to use the code n instead.
>
> For example:
> nGGG:
> sumformal('y,1, n, x*y^3 + y)
> or
> GGGDn
> sumformal(1, n, x*y^3 + y, 'y)
>
> Cheers,
> Bill.
>