new branch bill-closure-context

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <20200425150338.GC17625@yellowpig>
Dear PARI developers,

I have created a new git branch 'bill-closure-context'
which change the way closures contexts are generated,
while preserving backward compatibility.

In the following example, with the master branch:

? my(smallstuff=[1,2,3],bigstuff=vector(1000,i,i));f(i)=smallstuff[i];
? sizebyte(f)
%4 = 32520

This is because f include a copy of bigstuff.

In the branch

? my(smallstuff=[1,2,3],bigstuff=vector(1000,i,i));f(i)=smallstuff[i];
? sizebyte(f)
%2 = 512
? f
%3 = (i)->my(smallstuff=[1,2,3],bigstuff);smallstuff[i]

The compiler now detects that the value of bigstuff is not accessible by
f, so it does not store it in f. However it still lets the variable
declaration.

This mechanism should fix a number of usability issues with closures.

However the code is not well-tested, so if you have code that make heavy
use of closures, please test.

Cheers,
Bill
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.