From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] First batch of numerics changes Date: Fri, 28 Jan 2011 18:36:54 -0500 Message-ID: <8762t84n3d.fsf@yeeloong.netris.org> References: <87lj2762xc.fsf@yeeloong.netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1296259029 25490 80.91.229.12 (28 Jan 2011 23:57:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 28 Jan 2011 23:57:09 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jan 29 00:57:02 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PiyBX-0004zm-Oo for guile-devel@m.gmane.org; Sat, 29 Jan 2011 00:56:59 +0100 Original-Received: from localhost ([127.0.0.1]:59437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Piy1h-00072U-7t for guile-devel@m.gmane.org; Fri, 28 Jan 2011 18:46:49 -0500 Original-Received: from [140.186.70.92] (port=37128 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PixzT-0006HN-1S for guile-devel@gnu.org; Fri, 28 Jan 2011 18:44:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PixsO-0007Zc-Nh for guile-devel@gnu.org; Fri, 28 Jan 2011 18:37:13 -0500 Original-Received: from world.peace.net ([216.204.32.208]:39645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PixsO-0007Xu-KM for guile-devel@gnu.org; Fri, 28 Jan 2011 18:37:12 -0500 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=freedomincluded) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1Pixs8-00059q-Ne; Fri, 28 Jan 2011 18:36:56 -0500 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1Pixs6-0002RM-PC; Fri, 28 Jan 2011 18:36:54 -0500 In-Reply-To: (Andy Wingo's message of "Fri, 28 Jan 2011 12:41:20 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 216.204.32.208 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11390 Archived-At: Andy Wingo writes: > I don't understand this change: > >> From c42d03050ea0f96556e73e405e530b78bb85aba7 Mon Sep 17 00:00:00 2001 >> From: Mark H Weaver >> Date: Wed, 26 Jan 2011 02:56:20 -0500 >> Subject: [PATCH] Add case for fractions with differing SCM_CELL_TYPE to scm_equal_p >> >> * libguile/eq.c (scm_equal_p): Add a special case for fractions with >> differing SCM_CELL_TYPE, which might nonetheless be considered equal >> (due to the use of 0x10000 as a flag), to scm_equal_p. This code >> was already present in scm_eqv_p. To be honest, I didn't investigate until now. I just wanted to make `equal?' act the same as `eqv?' for numbers, and it seemed prudent to copy that code over. I didn't consider the possibility that the code was useless, but now I see that it should be removed from both places. > In what case would two fractions ever not have the same SCM_CELL_TYPE ? > I don't understand this discussion of flags. AFAICS fractions have their > own tc16, and no flags are ever set. Judging from the following test case at the end of numbers.test, I guess there was a tentative plan to implement a "lazy reduction bit" for fractions, presumably meaning that they would not be reduced to lowest terms until the first time their numerator or denominator was accessed. > (with-test-prefix "equal?" > (pass-if > > ;; lazy reduction bit for rationals should not affect equal? > (equal? 1/2 ((lambda (x) (denominator x) x) 1/2)))) However, from looking at the code for handling fractions, it is clear that this plan was never implemented. I will submit a patch to get rid of that cruft. > Furthermore I would think that the `if (SCM_NUMP (x))' block in > scm_eqv_p could use a switch statement instead of a bunch of ifs. Agreed, I will do it. Mark