unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: guile-devel@gnu.org
Subject: Add ‘expt’ to the list of effect-free primitives
Date: Sun, 16 May 2021 21:00:23 +0200	[thread overview]
Message-ID: <5c254b88a2ae10ea1eb7a1f23bba32abe9bc1e7f.camel@telenet.be> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 4 bytes --]




[-- Attachment #1.2: 0001-Add-expt-to-the-list-of-effect-free-primitives.patch --]
[-- Type: text/x-patch, Size: 1501 bytes --]

From b9d0faf091c316d0811d73df9eea134dc23f8ed6 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Sun, 16 May 2021 20:32:34 +0200
Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=98expt=E2=80=99=20to=20the=20list?=
 =?UTF-8?q?=20of=20effect-free=20primitives.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I find myself writing code like (- (expt 2 32) 1)
lately. Let's allow constant-folding that.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*):
  Add 'expt'.
---
 module/language/tree-il/primitives.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/module/language/tree-il/primitives.scm b/module/language/tree-il/primitives.scm
index 1cc7907a8..7f3746b4f 100644
--- a/module/language/tree-il/primitives.scm
+++ b/module/language/tree-il/primitives.scm
@@ -48,6 +48,7 @@
     memq memv
     = < > <= >= zero? positive? negative?
     + * - / 1- 1+ quotient remainder modulo exact->inexact
+    expt
     ash logand logior logxor lognot logtest logbit?
     sqrt abs floor ceiling sin cos tan asin acos atan
     not
@@ -171,7 +172,7 @@
   `(values
     eq? eqv? equal?
     = < > <= >= zero? positive? negative?
-    ash logand logior logxor lognot logtest logbit?
+    expt ash logand logior logxor lognot logtest logbit?
     + * - / 1- 1+ sqrt abs quotient remainder modulo exact->inexact
     floor ceiling sin cos tan asin acos atan
     not
-- 
2.31.1


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

             reply	other threads:[~2021-05-16 19:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 19:00 Maxime Devos [this message]
2021-05-18 17:25 ` Add ‘expt’ to the list of effect-free primitives lloda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c254b88a2ae10ea1eb7a1f23bba32abe9bc1e7f.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).