Bill Allombert on Sun, 14 Jan 2024 13:05:47 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Is it possible to implement closures in PARI?
|
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: Is it possible to implement closures in PARI?
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Sun, 14 Jan 2024 13:05:41 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705233944; c=relaxed/relaxed; bh=PV9INQG7BkaxBJzSBhdhXWnPK2teL9suamn/P6ClzV0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; b=htPITsiIShdTtwOrj1ePGxzrgeYME7PvmCx4DfZF7AAQR+B3eXbVdloGQMXyu2zBqHqTrroR0df2Pv7/sWdKXVnU7l+X/aL9ORcBrRhZMlvDuej/Ri8aY9uXN3p4Ftpf/mUTCnFkHSg9RfJfepnT+BwBsr0sWwA3P6aoTRWqm1vFuZ0cx5sDL9MQIbWDiRaVpki9bJE75t3EfjuUAAby9T089Cd12f8VqSKcvSMQ1nQdy3X4GoFxLkcQ3wbHvJHjX/eUyr7M1QjJHvI+hdx8zgZKvqyKz/lU3KAX3YMsmhJ29IkvVrX9B9H+9HU4CjjLn5WaFTeI7fObyy5c1Hpn2Iv2qFoaHnHdHpOKyafEHDbNCpagPPFEvCVUE1Rw8py/twKTPq5avbcG/b5HUMxCCMb33Tw/CE/ryupcvTp6NLN0XPfnWG7Wje0QSC1WZe3ZSXSeltUcfdjjtOVQxY+J4m7C+iIYOQRdLysUwrCfLGRSCH5j1e0VN+Mot61qTqHWVbIjY7pdXoVOKJzt8eKbt2TVio/ZXv5ohrcpqR/IRi3MLusd5KMlhORmg4DVBDNO6TT3st87CmTo17fKtyfrvMvUIzVHn9Qd1tv9P6SuA3N1Trn1N4wur6tsddGRTf4e09/x6YlReSZgSqBFx/FV7m765tLDo4cmH2YyRU8psNA=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705233944; cv=none; b=fLSSqmeD8DSswnCJPQ8b+rPvwCpROeWIgFUoF09ySr5p9aPeBkP0eaKfKunMmbvFqjy1iBkIhl+2s+5Tm+xt/QPWtswErK/G5HqVfySfBSc6dBqA6/IufECLtIQ9JfQL4G7/h4LcISuq+8SAV+30GaNqRJKXTONfab4vT6h8jmQrzAPVoW4HJiukfkQEY7iSwIiIyDWYSCcVxxUTxI5u4jNvDVL+KYCLbcBpr9sZLftMpRdh7c0IG470WuxY1esYY/pXpoX47Kxj0jtyKFvWOjilTSbtXDj2a5bHZ8XS7YfRXWD0OlhCGHlClrJnOFF5roKmSR3I0vAZ2uW8mGmJwfCVg45w7npVYv/sN/cf1T+xRS9nUFq4hKwqBfyp2sWD3PeAIrOgEkzI24wum7VZyul6wrRnHGce2J4sk/JjpExY8X9uHYJtbqF1tj/PKKA323mamHzL3lEaQmXy7xOZeB9IZAJrsOfnJ+T3F1zkvfw0XsFSztLrOndz/mC07ykOjJUY4ZDfY7SftDzmgQCQjaZjyMYUekG0kAwYbvQwDM9gVo6qMekYoB/DrQ+438NupTDEbKzWqBnR32/TIBUQLDIP3XjCk0/G+73AXlY9CYIb1FM88cTrQVdy9p0c4bdnCXrMgCxar58Gt+bGf3acdtqh8z1oj8BTGPfIkXiOORA=
- Authentication-results: smail; arc=none
- Delivery-date: Sun, 14 Jan 2024 13:05:47 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1705233944; bh=PV9INQG7BkaxBJzSBhdhXWnPK2teL9suamn/P6ClzV0=; h=Date:From:To:Subject:References:In-Reply-To:From; b=SMMJ1jgHy15qOzFQYo5Dcdpmcj2bozy+JjLuL4MSif05yfzpx2fr9YBtEU/TSzBWC +0YZV9Nhr5OB6B2wvaI+zBpuPe7lW6f+vmQMesGzc/O4gZo6Whfrs/mtTu1CDjy500 pBKLzJDmweZtN2FEOLNmCLbSPwqwPp9dNNrLe/dZjFH8pEl/7l5WwBC8hi0y4w9Kzp ja8yc47u4i6r3sUaQnR1I0aY7bKmcjy9aSAUw1LGk6lmugOlJf8ULFv/Qy/pvLy0Rp QgIDMIfqmmB8omowXIh1QAUVQ+sQ2Zmeh4jyCZ4p4t2PR95zC5scBeKT31B3OIcajQ EK2Z8oOxVixl6K+KRgFBYqUYEwaFxiGH7E2C5iyhmzash4kKG101ziufkwImJn9Kyh BnKxY/e/840yZXwkJA+LjnzuZpbxXwDnLDUqtDcXcEtax/NWL4xYruzgUnhUvvgh3+ 79cPUJlNeffQPm0TrgXkcTpfr1/Fis1EWW6/3tA6DueiFof2+v+d88ka+/ngxWKfMx q5oqKE4KvaD95ruckHOVHZYLRJJNtzsPHAFO5c7vlpttBmxccX6tlHKVQdRa4i/WXi w9/AoZh/YZwEmK8b8Us3HWR+nSm92pXsk+JI12w/s6sukRIzy4/5HZ6hfPNC++VFMA 7hqTKRNSmhpJbB1960I3Xer4=
- In-reply-to: <ZaBWDw3RT3bCM0Xw@login.math.berkeley.edu>
- Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
- References: <ZaBWDw3RT3bCM0Xw@login.math.berkeley.edu>
On Thu, Jan 11, 2024 at 12:56:47PM -0800, Ilya Zakharevich wrote:
> Currently, PARI supports anonymous subroutines memoizing values of
> lexical variables (at the moment of creation). Is it theoretically
> possible to implement¹⁾ closures instead? — In other words: are
> closures compatible with the PARI⸣s memory model?
Probably not. The problem is well-documented:
<https://en.wikipedia.org/wiki/Funarg_problem>
The problem is that the variable scope might end before the closure scope,
so the closure would have a reference to a freed variable, so we would need
smarter memory management than the stack.
Also it would not be compatible with parallelism, which require closures to
be immutable.
Cheers,
Bill