Re: SRFI-143 Fixnums (was Generalized-Arrays egg v1.0.1)
On 4/22/24 22:20, Diego wrote: On Monday, April 22nd, 2024 at 11:56 PM, Jeremy Steward wrote: Sorry to reply to myself, but I've provided some better patches now, see attached. Whoops, I got this in the middle of pushing the previous change. I'll try and apply the new patches. Thanks for this. Diego Thanks for applying those patches and pushing up v1.0.0. I tested the re-exports locally and they seem to no longer cause performance problems on transducers or generalized-arrays, and new versions of those should be up shortly. Cheers, -- Jeremy Steward
Re: SRFI-143 Fixnums (was Generalized-Arrays egg v1.0.1)
On Monday, April 22nd, 2024 at 11:56 PM, Jeremy Steward wrote: > Sorry to reply to myself, but I've provided some better patches now, see > attached. Whoops, I got this in the middle of pushing the previous change. I'll try and apply the new patches. Thanks for this. Diego
Re: SRFI-143 Fixnums (was Generalized-Arrays egg v1.0.1)
Huh, looking through the log I guess I implemented the variadic operators, but I don't remember why? > Anyways, happy to continue to get this out to folks. I don't know to > what extent users are currently using SRFI-143 so I'd be wary to push > this out, but I went to the liberty of bumping the version to 1.0.0 > since this would definitely be a major breakage of the API. I grepped through all the .egg files in eggs-5-latest and it seems only SRFI-217 and integer-map depend on SRFI-143; they do not appear to make use of the variadic operators. This is confirmed by passing tests even when building these eggs with a patched SRFI-143. > I don't have a SourceHut account, but from what I know of SourceHut I > believe either approach can be made to work (I may need to set up > git-send-email). For what it's worth, I've done the hard work of > converting everything to an R7RS egg as well as fixing the tests / arity > of every procedure to match that of (chicken fixnum) and what I presume > to be John's original intent with the SRFI. Thanks. I have applied your patch, tagged the commit, and pushed it. I haven't actually been using sourcehut for that long relatively, so I'm not sure what's required to give you access to the repo. At a glance it seems easy to add other users by account name, but if there's another way I could look into it (or if we'd simply want to move the egg somewhere else, fine by me). I'll try to be at least a little more active on email (IRC, if I ever get around to setting it up again) going forward to keep track of this and my other eggs, should they come up. Diego
Re: SRFI-143 Fixnums (was Generalized-Arrays egg v1.0.1)
Sorry to reply to myself, but I've provided some better patches now, see attached. I went ahead and fixed the Makefile and SVNWiki pages as well. I can't run test-new-egg but salmonella passes just fine. Cheers, -- Jeremy StewardFrom 0fe5cff9482bc6a11594d907128ddbcad562976c Mon Sep 17 00:00:00 2001 From: Jeremy Steward Date: Mon, 22 Apr 2024 21:54:21 -0600 Subject: [PATCH 3/3] Update svnwiki page with appropriate docs --- srfi-143.svnwiki | 43 +-- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/srfi-143.svnwiki b/srfi-143.svnwiki index 7f326e9..fd4be26 100644 --- a/srfi-143.svnwiki +++ b/srfi-143.svnwiki @@ -52,11 +52,9 @@ in the same way as {{(chicken fixnum}}). === Deviations from the specification -In the CHICKEN implementation, {{fx+}}, {{fx-}}, and {{fx*}} are variadic, -implemented with {{foldr}}, {{foldl}}, and {{foldr}}, respectively. For -completeness, a variadic {{fx/}} is provided as well, implemented with -{{foldl}}. It's not clear that this is much more useful than the SRFI's -{{fxquotient}}. +All procedures in this library are 2-arity wherever possible. The original +SRFI-143 document lists these procedures as variadic, but for compatibility +with {{(chicken fixnum)}} these are kept to 2-arity and re-exported. === Specification @@ -105,23 +103,23 @@ Bound to the value {{-2^w-1}}, the smallest representable fixnum. (R6RS Returns {{#t}} if obj is an exact integer within the fixnum range, and {{#f}} otherwise. -(fx=? i ...) +(fx=? i j) Semantically equivalent to {{=}}. -(fx +(fx Semantically equivalent to {{<}}. -(fx>? i ...) +(fx>? i j) Semantically equivalent to {{>}}. -(fx<=? i ...) +(fx<=? i j) Semantically equivalent to {{<=}}. -(fx>=? i ...) +(fx>=? i j) Semantically equivalent to {{>=}}. @@ -145,21 +143,21 @@ Semantically equivalent to {{odd?}}. Semantically equivalent to {{even?}}. -(fxmax i j ...) +(fxmax i j) Semantically equivalent to {{max}}. -(fxmin i j ...) +(fxmin i j) Semantically equivalent to {{min}}. Basic arithmetic -(fx+ i ...) +(fx+ i j) Semantically equivalent to {{+}}. -(fx- i ...) +(fx- i j) Semantically equivalent to {{-}}. @@ -167,11 +165,11 @@ Semantically equivalent to {{-}}. Semantically equivalent to {{-}}, but accepts exactly one argument. -(fx* i ...) +(fx* i j) Semantically equivalent to {{*}}. -(fx/ i ...) +(fx/ i j) Semantically equivalent to {{(foldr quotient i rest-args)}}. @@ -243,15 +241,15 @@ are dropped for brevity and compatibility. Semantically equivalent to {{bitwise-not}}. -(fxand i ...) +(fxand i j) Semantically equivalent to {{bitwise-and}}. -(fxior i ...) +(fxior i j) Semantically equivalent to {{bitwise-ior}}. -(fxxor i ...) +(fxxor i j) Semantically equivalent to {{bitwise-xor}}. @@ -331,17 +329,17 @@ Jaffer, Taylor Campbell, and the R6RS editors. === Copyright Copyright (C) John Cowan (2016). All Rights Reserved. - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -352,6 +350,7 @@ Jaffer, Taylor Campbell, and the R6RS editors. === Version history +* 1.0.0 - Convert egg to R7RS library & convert variadic procedures to 2-arity procedures. * 0.4.1 - Fix bug due to calling fixnum procedures with wrong number of arguments * 0.4 - Implement variadic arithmetic operators, use fixnum operations internally * 0.3 - Reorganize and reduce files -- 2.43.0 From c9e35def19b4f7c0753180ac395eb0f009b0ac60 Mon Sep 17 00:00:00 2001 From: Jeremy Steward Date: Mon, 22 Apr 2024 21:29:41 -0600 Subject: [PATCH 2/3] Add chicken-lint to Makefile / clean up makefile Some of the commands were a bit ??? so I did a bit of cleanup on the Makefile. --- Makefile | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index d613d59..7deea33 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,37 @@ -CHICKEN_CLEAN := chicken-clean -CHICKEN_INSTALL := chicken-install -SALMONELLA := salmonella -SALMONELLA_LOG := salmonella.log -SALMONELLA_LOG_VIEWER := salmonella-log-viewer -SRFI := srfi-143.scm -TEST_NEW_EGG := test-new-egg +CHICKEN_CLEAN := chicken-clean
Re: SRFI-143 Fixnums (was Generalized-Arrays egg v1.0.1)
On 4/22/24 14:55, Diego wrote: Hi all, Sorry to be very late/unresponsive to this discussion. As I understand it from reading the email thread, there are several optimizations and changes to SRFI-143 that would make it more performant or inline with the intent of the original SRFI. Heyo! Better late than never! I think there's two things being discussed: 1. SRFI-143 as it exists is rather slow compared to (chicken fixnum) 2. There seems to be an errata / post finalization note in SRFI-143 (the text) that needs to be brought up regarding 2-arity vs. variadic procedures in the spec. John mentioned he would pursue this, although looking at the archives I haven't seen it yet. I have unfortunately not had much time for scheme in the past couple years, and though I'd love to get back to it eventually, I'd hate to simply sit on the sources for this (or any other eggs I maintain) without allowing for it to evolve. I understand this feeling. Look at generalized-arrays (thread topic), I sat on it for years! I'd be happy to give Jeremy and anyone else interested in this effort read/write access to the sources at https://git.sr.ht/~dieggsy/srfi-143, or transfer the egg to a different maintainer/repo entirely if that approach is preferred. Diego I don't have a SourceHut account, but from what I know of SourceHut I believe either approach can be made to work (I may need to set up git-send-email). For what it's worth, I've done the hard work of converting everything to an R7RS egg as well as fixing the tests / arity of every procedure to match that of (chicken fixnum) and what I presume to be John's original intent with the SRFI. See the attached file for the full patch. One thing I did not do was update the svnwiki page in the repo. I can definitely do this but I only spent about an hour or so on this and some plugin in my editor is messing with the formatting. (classic excuse right?) Anyways, happy to continue to get this out to folks. I don't know to what extent users are currently using SRFI-143 so I'd be wary to push this out, but I went to the liberty of bumping the version to 1.0.0 since this would definitely be a major breakage of the API. Cheers, -- Jeremy StewardFrom d9d3a770afc54faf12558f59e37a33db7a016587 Mon Sep 17 00:00:00 2001 From: Jeremy Steward Date: Mon, 22 Apr 2024 20:56:03 -0600 Subject: [PATCH] Convert egg to R7RS egg & variadic procedures to 2-arity --- carries.scm | 63 --- srfi-143-impl.scm | 98 - srfi-143.egg | 12 ++- srfi-143.release-info | 1 + srfi-143.scm | 246 +++--- srfi-143.sld | 83 ++ tests/r6rs-test.scm | 176 -- tests/run.scm | 34 +++--- 8 files changed, 270 insertions(+), 443 deletions(-) delete mode 100644 carries.scm delete mode 100644 srfi-143-impl.scm create mode 100644 srfi-143.sld delete mode 100644 tests/r6rs-test.scm diff --git a/carries.scm b/carries.scm deleted file mode 100644 index 8c2253c..000 --- a/carries.scm +++ /dev/null @@ -1,63 +0,0 @@ - Generic implementation of carry functions from the R6RS standard. - -;;; These implementations of fx+/carry, fx-/carry, and fx*/carry -;;; are very inefficient, and should be replaced by proper -;;; assembly language operations if at all possible. -;;; Furthermore, there are no tests for them, -;;; because of their dependency on fx-width. - -(define exp-width (expt 2 fx-width)) - -(define (fx+/carry i j k) - (let*-values (((s) (+ i j k)) -((q r) (balanced/ s exp-width))) -(values r q))) - -(define (fx-/carry i j k) - (let*-values (((d) (- i j k)) -((q r) (balanced/ d exp-width))) -(values r q))) - -(define (fx*/carry i j k) - (let*-values (((s) (+ (* i j) k)) -((q r) (balanced/ s exp-width))) -(values r q))) - -;;; Helper functions from SRFI 151 - -(define (floor-/+ n d) - (let ((n (- 0 n))) -(let ((q (quotient n d)) (r (remainder n d))) - (if (zero? r) - (values (- 0 q) r) - (values (- (- 0 q) 1) (- d r)) - -(define (ceiling-/- n d) - (let ((n (- 0 n)) (d (- 0 d))) -(let ((q (quotient n d)) (r (remainder n d))) - (if (zero? r) - (values q r) - (values (+ q 1) (- d r)) - -(define (euclidean/ n d) - (if (and (exact-integer? n) (exact-integer? d)) - (cond ((and (negative? n) (negative? d)) (ceiling-/- n d)) -((negative? n) (floor-/+ n d)) -((negative? d) - (let ((d (- 0 d))) - (values (- 0 (quotient n d)) (remainder n d -(else (values (quotient n d) (remainder n d - (let ((q (if (negative? d) (ceiling (/ n d)) (floor (/ n d) -(values q (- n (* d q)) - -(define (balanced/ x y) - (call-with-values - (lambda () (euclidean/ x y)) -(lambda (q r) - (cond ((< r (abs (/ y 2))) -