From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25085 invoked by alias); 18 Feb 2014 16:30:15 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 25071 invoked by uid 89); 18 Feb 2014 16:30:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail.theptrgroup.com Received: from mail.theptrgroup.com (HELO mail.theptrgroup.com) (71.178.251.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Feb 2014 16:30:12 +0000 Received: from [10.11.21.30] (unknown [10.11.21.30]) by mail.theptrgroup.com (Postfix) with ESMTPS id D77101E06F for ; Tue, 18 Feb 2014 11:30:10 -0500 (EST) From: Jamison Hope Content-Type: multipart/signed; boundary="Apple-Mail=_FB4CFF37-6208-466F-B750-07E9E41406D2"; protocol="application/pgp-signature"; micalg=pgp-sha1 Message-Id: <01FB0C75-CF10-420C-BEAB-C18E2052C097@theptrgroup.com> Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: SRFI-60 Date: Tue, 18 Feb 2014 16:30:00 -0000 References: <530307BD.4070501@bothner.com> To: "kawa@sourceware.org list" In-Reply-To: <530307BD.4070501@bothner.com> X-IsSubscribed: yes X-SW-Source: 2014-q1/txt/msg00047.txt.bz2 --Apple-Mail=_FB4CFF37-6208-466F-B750-07E9E41406D2 Content-Type: multipart/mixed; boundary="Apple-Mail=_462EF1DB-CC91-4296-8F1D-7C3179ABD89B" --Apple-Mail=_462EF1DB-CC91-4296-8F1D-7C3179ABD89B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Content-length: 1400 On Feb 18, 2014, at 2:11 AM, Per Bothner wrote: > On 02/17/2014 10:53 PM, Jamison Hope wrote: >> I saw that SRFI-60 was almost there, so I went ahead and implemented the= rest of it. >=20 > Thanks! As low hanging fruit go, this one was resting on the ground. :-) >> Since there are argument order differences compared to existing numbers.= scm procedures, I figure this one should probably require an explicit requi= re/import, so it can go in the gnu.kawa.slib package next to srfi1.scm. Ev= en so, I wonder whether it might be a good idea to remove the builtin logbi= t? (which is just an alias for bitwise-set-bit? anyway). >=20 > Yes, I think we should remove the old builtin logbit? I notice Common Li= sp's > logbitp uses the (logbitp index integer) order. I suspect the (logbit? i= nteger index) > order is just a bug - it doesn't match any other Scheme I've found. OK. That probably still argues for keeping the SRFI-60 version out of the = builtins -- if anybody is using the old function by that name and not 'bitw= ise-bit-set?', it'll be better for them to see a compiler error than to hav= e the semantics altered silently (I wouldn't want to be the one to track do= wn that bug!). Here's a patch which adds SRFI-60, updates require.java and ImportFromLibra= ry.java, and removes logbit? from Scheme.java. -- Jamison Hope The PTR Group www.theptrgroup.com --Apple-Mail=_462EF1DB-CC91-4296-8F1D-7C3179ABD89B Content-Disposition: attachment; filename=srfi60.patch Content-Type: application/octet-stream; name="srfi60.patch" Content-Transfer-Encoding: 7bit Content-length: 7924 Index: ChangeLog =================================================================== --- ChangeLog (revision 7818) +++ ChangeLog (working copy) @@ -1,3 +1,7 @@ +2014-02-18 Jamison Hope + + * build.xml (slib-scm-classes): Add srfi60.scm. + 2014-02-06 Per Bothner * build.xml (commonlisp-scm-classes): Make sure to compile Index: build.xml =================================================================== --- build.xml (revision 7818) +++ build.xml (working copy) @@ -586,6 +586,7 @@ + Index: gnu/kawa/slib/ChangeLog =================================================================== --- gnu/kawa/slib/ChangeLog (revision 7818) +++ gnu/kawa/slib/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2014-02-18 Jamison Hope + + * srfi60.scm: New implementation of SRFI-60. + * Makefile.am: Update accordingly. + 2014-02-06 Seth Alves * srfi13.scm (string-trim-right): Import bug-fix from reference Index: gnu/kawa/slib/Makefile.am =================================================================== --- gnu/kawa/slib/Makefile.am (revision 7818) +++ gnu/kawa/slib/Makefile.am (working copy) @@ -21,7 +21,7 @@ java_SCM = DefineRecordType.scm enums.scm readtable.scm \ srfi1.scm srfi2.scm \ conditions.scm srfi13.scm srfi14.scm srfi34.scm \ - srfi37.scm srfi69.scm pregexp.scm \ + srfi37.scm srfi60.scm srfi69.scm pregexp.scm \ Streams.scm StreamsDerived.scm StreamsPrimitive.scm StreamsType.scm \ genwrite.scm pp.scm ppfile.scm printf.scm ralists.scm syntaxutils.scm \ cut.scm testing.scm $(XML_SCM) $(AWT_SCM) $(SWING_SCM) Index: gnu/kawa/slib/srfi60.scm =================================================================== --- gnu/kawa/slib/srfi60.scm (revision 0) +++ gnu/kawa/slib/srfi60.scm (working copy) @@ -0,0 +1,81 @@ +;; SRFI-60 implementation for Kawa (almost everything is already built +;; in, but some of the names differ slightly). +;; Copyright (C) 2014 by Jamison Hope. The implementations of +;; integer->list, list->integer, and booleans->integer were taken with +;; slight modifications from the reference implementation of SRFI-60, +;; which is copyright (C) 1991, 1993, 2001, 2003, 2005 Aubrey Jaffer +; +;Permission to copy this software, to modify it, to redistribute it, +;to distribute modified versions, and to use it for any purpose is +;granted, subject to the following restrictions and understandings. +; +;1. Any copy made of this software must include this copyright notice +;in full. +; +;2. I have made no warranty or representation that the operation of +;this software will be error-free, and I am under no obligation to +;provide any services, by way of maintenance, update, or otherwise. +; +;3. In conjunction with products arising from the use of this +;material, there shall be no use of my name in any advertising, +;promotional, or sales literature without prior written consent in +;each case. + +(module-compile-options warn-unknown-member: #t) + +(provide 'srfi-60) + +;;; These procedures are already Kawa built-ins and do not need to be +;;; defined here: logand/bitwise-and, logior/bitwise-ior, +;;; logxor/bitwise-xor, lognot/bitwise-not, bitwise-if, logtest, +;;; logcount, integer-length, and ash/arithmetic-shift. + +;;; These procedures alias functionality provided by built-ins with +;;; differing names: + +(define bitwise-merge bitwise-if) +(define any-bits-set? logtest) +(define bit-count logcount) +(define log2-binary-factors bitwise-first-bit-set) +(define first-set-bit bitwise-first-bit-set) +(define bit-field bitwise-bit-field) +(define reverse-bit-field bitwise-reverse-bit-field) + +;;; These procedures are similar to built-ins but with arguments +;;; reordered: + +(define (logbit? index::int n::integer) ::boolean + (bitwise-bit-set? n index)) +(define bit-set? logbit?) + +(define (copy-bit-field to::integer from::integer start::int end::int) + ::integer + (bitwise-copy-bit-field to start end from)) + +(define (rotate-bit-field n::integer count::int start::int end::int) + ::integer + (bitwise-rotate-bit-field n start end count)) + +;;; This procedure has a slightly different signature compared to the +;;; built-in bitwise-copy-bit: the first two arguments are swapped and +;;; the last is a boolean instead of an int +(define (copy-bit index::int from::integer bit::boolean) + ::integer + (bitwise-copy-bit from index (if bit 1 0))) + +;;; These procedures are entirely new, with implementations derived +;;; from the SRFI-60 reference. +(define (integer->list k::integer #!optional (len ::int (integer-length k))) + ::list + (do ((idx ::int (- len 1) (- idx 1)) + (k ::integer k (ash k -1)) + (lst ::list '() (cons (odd? k) lst))) + ((< idx 0) lst))) + +(define (list->integer bools::list) ::integer + (do ((bs bools (cdr bs)) + (acc ::integer 0 (if (car bs) (+ acc acc 1) (+ acc acc)))) + ((null? bs) acc))) + +(define (booleans->integer . bools) + (list->integer bools)) Property changes on: gnu/kawa/slib/srfi60.scm ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Rev Id \ No newline at end of property Index: kawa/ChangeLog =================================================================== --- kawa/ChangeLog (revision 7818) +++ kawa/ChangeLog (working copy) @@ -1,3 +1,11 @@ +2014-02-18 Jamison Hope + + * standard/Scheme.java (initScheme): Remove 'logbit?', since it + just an alias for 'bitwise-bit-set?' and happens to conflict with + the semantics of SRFI-60 'logbit?'. + * standard/ImportFromLibrary.java (SRFI97Map): Update for SRFI-60. + * standard/require.java (featureMap): Likewise. + 2014-02-17 Per Bothner * standard/define.java: Implement 'define-early-constant'. Index: kawa/standard/ImportFromLibrary.java =================================================================== --- kawa/standard/ImportFromLibrary.java (revision 7818) +++ kawa/standard/ImportFromLibrary.java (working copy) @@ -63,7 +63,7 @@ { "54", "cat", MISSING }, { "57", "records", MISSING }, { "59", "vicinities", MISSING }, - { "60", "integer-bits", MISSING }, + { "60", "integer-bits", "gnu.kawa.slib.srfi60" }, { "61", "cond", MISSING }, { "63", "arrays", MISSING }, { "64", "testing", "gnu.kawa.slib.testing" }, Index: kawa/standard/Scheme.java =================================================================== --- kawa/standard/Scheme.java (revision 7818) +++ kawa/standard/Scheme.java (working copy) @@ -599,8 +599,6 @@ defProcStFld("lognot", "gnu.kawa.functions.BitwiseOp", "not"); defProcStFld("logop", "kawa.lib.numbers"); defProcStFld("bitwise-bit-set?", "kawa.lib.numbers"); - defProcStFld("logbit?", "kawa.lib.numbers", - Language.mangleNameIfNeeded("bitwise-bit-set?")); defProcStFld("logtest", "kawa.lib.numbers"); defProcStFld("bitwise-bit-count", "kawa.lib.numbers"); defProcStFld("logcount", "kawa.lib.numbers"); Index: kawa/standard/require.java =================================================================== --- kawa/standard/require.java (revision 7818) +++ kawa/standard/require.java (working copy) @@ -97,6 +97,7 @@ map("srfi-41-streams-type", SLIB_PREFIX + "StreamsType"); map("srfi-41-streams-primitive", SLIB_PREFIX + "StreamsPrimitive"); map("srfi-41-streams-derived", SLIB_PREFIX + "StreamsDerived"); + map("srfi-60", SLIB_PREFIX + "srfi60"); map("srfi-64", SLIB_PREFIX + "testing"); map("testing", SLIB_PREFIX + "testing"); map("srfi-69", SLIB_PREFIX + "srfi69"); --Apple-Mail=_462EF1DB-CC91-4296-8F1D-7C3179ABD89B Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=iso-8859-1 Content-length: 1 --Apple-Mail=_462EF1DB-CC91-4296-8F1D-7C3179ABD89B-- --Apple-Mail=_FB4CFF37-6208-466F-B750-07E9E41406D2 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail Content-length: 204 -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iEYEARECAAYFAlMDipQACgkQ0clDhDhsXxhHyQCfRrnEWqaCVpBlYno3mKSVogkZ hZsAn0HbFe/FQeGZ3kp4etTYuPLGAIV0 =nJff -----END PGP SIGNATURE----- --Apple-Mail=_FB4CFF37-6208-466F-B750-07E9E41406D2--