From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: guile-2.0 and slib Date: Mon, 30 Dec 2013 16:30:51 +0000 Message-ID: <20131230163051.3ae109ff@laptop.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1388421061 18251 80.91.229.3 (30 Dec 2013 16:31:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Dec 2013 16:31:01 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Dec 30 17:31:07 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VxfkB-0002tB-BY for guile-user@m.gmane.org; Mon, 30 Dec 2013 17:31:07 +0100 Original-Received: from localhost ([::1]:58876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VxfkA-00077M-OM for guile-user@m.gmane.org; Mon, 30 Dec 2013 11:31:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vxfju-000778-TM for guile-user@gnu.org; Mon, 30 Dec 2013 11:30:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vxfjl-0003S5-6O for guile-user@gnu.org; Mon, 30 Dec 2013 11:30:50 -0500 Original-Received: from avasout05.plus.net ([84.93.230.250]:35546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vxfjk-0003RT-NS for guile-user@gnu.org; Mon, 30 Dec 2013 11:30:41 -0500 Original-Received: from laptop.homenet ([146.90.115.209]) by avasout05 with smtp id 7sWd1n0024X8WYq01sWeaA; Mon, 30 Dec 2013 16:30:38 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JpbI8qIC c=1 sm=1 tr=0 a=+gAbPKVUXXSIXA//6Z8Igw==:117 a=+gAbPKVUXXSIXA//6Z8Igw==:17 a=0Bzu9jTXAAAA:8 a=a7_E5ZZ9eK8A:10 a=kj9zAlcOel0A:10 a=g_0wNEBgAAAA:8 a=mDV3o1hIAAAA:8 a=XeiEMp606rsA:10 a=qvXFG192B-sb-aoFEBcA:9 a=tGHigNTbNA37T7mt:21 a=FZhV-WBR88eAzBzA:21 a=CjuIK1q_8ugA:10 Original-Received: from laptop.homenet (localhost [127.0.0.1]) by laptop.homenet (Postfix) with ESMTP id 8F355543796 for ; Mon, 30 Dec 2013 16:30:52 +0000 (GMT) X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 84.93.230.250 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10948 Archived-At: Hi, Although some of slib in release 3b4 now works with guile-2.0, slib's srfi-63 arrays do not. Although few will probably want to use srfi-63 arrays except for compatibility reasons, a number of other slib procedures do so. This causes other parts of slib which use arrays to fail to compile with guile-2.0. This is because helper procedures for sfri-63 arrays are implemented in slib's guile-2.init by reference to guile's former uniform arrays, which were removed in guile-2.0. A patch is attached which substitutes guile's typed arrays instead. This comprises a direct translation from uniform array syntax to typed array syntax. The make-typed-wrapper helper procedure does the same as the former make-uniform-wrapper, which includes the feature that a call to (A:fixN32b 4) will produce a prototype of type #0u32 (rank 0), whereas a call to (A:fixN32b) will produce a prototype of type #u32 (rank 1). This doesn't matter - either seems to be conforming and work correctly as a prototype - but I wasn't clear why one format was not chosen for both. If a rank 1 prototype were to be used in both cases, make-typed-array could be used in the wrapper in place of list->typed-array. The only substantive change in make-array is to test the prototype for an empty array. The former version for uniform arrays fails to compile with an empty prototype (array-ref is given an invalid index). However, srfi-63 states that "If the prototype has no elements, then the initial contents of the returned array are unspecified", which implies that it should compile. I hope this is an appropriate mailing list for slib related issues with guile. If not, any assistance on where it should go would be appreciated. Chris --- slib/guile-2.init.orig 2013-12-28 13:17:16.324936077 +0000 +++ slib/guile-2.init 2013-12-30 12:24:28.715147778 +0000 @@ -559,13 +559,16 @@ ra0)) (define (array:copy! dest source) (array-map! dest identity source)) -;; DIMENSIONS->UNIFORM-ARRAY and list->uniform-array in Guile-1.6.4 -;; cannot make empty arrays. + (define make-array (lambda (prot . args) - (dimensions->uniform-array args (array-prototype prot) - (apply array-ref prot - (map car (array-shape prot)))))) + (let ((fill (if (memv 0 (array-dimensions prot)) + *unspecified* + (apply array-ref prot (map car (array-shape prot)))))) + (apply make-typed-array + (array-type prot) + fill + args)))) (define (list->array rank proto lst) (define dimensions @@ -618,27 +621,24 @@ vect)) (define create-array make-array) -(define (make-uniform-wrapper prot) - (if (string? prot) (set! prot (string->number prot))) - (if prot - (lambda opt - (if (null? opt) - (list->uniform-array 1 prot (list prot)) - (list->uniform-array 0 prot (car opt)))) - vector)) -(define ac64 (make-uniform-wrapper "+i")) -(define ac32 ac64) -(define ar64 (make-uniform-wrapper "1/3")) -(define ar32 (make-uniform-wrapper "1.")) -(define as64 vector) -(define as32 (make-uniform-wrapper -32)) -(define as16 as32) -(define as8 as32) -(define au64 vector) -(define au32 (make-uniform-wrapper 32)) -(define au16 au32) -(define au8 au32) -(define at1 (make-uniform-wrapper #t)) +(define (make-typed-wrapper pair) + (lambda opt + (if (null? opt) + (list->typed-array (car pair) 1 (list (cdr pair))) + (list->typed-array (car pair) 0 (car opt))))) +(define ac64 (make-typed-wrapper '(c64 . 0.0+0.0i))) +(define ac32 (make-typed-wrapper '(c32 . 0.0+0.0i))) +(define ar64 (make-typed-wrapper '(f64 . 0.0))) +(define ar32 (make-typed-wrapper '(f32 . 0.0))) +(define as64 (make-typed-wrapper '(s64 . 0))) +(define as32 (make-typed-wrapper '(s32 . 0))) +(define as16 (make-typed-wrapper '(s16 . 0))) +(define as8 (make-typed-wrapper '(s8 . 0))) +(define au64 (make-typed-wrapper '(u64 . 0))) +(define au32 (make-typed-wrapper '(u32 . 0))) +(define au16 (make-typed-wrapper '(u16 . 0))) +(define au8 (make-typed-wrapper '(u8 . 0))) +(define at1 (make-typed-wrapper '(b . #f))) ;;; New SRFI-58 names ;; flonums