From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: Short circuiting behaviour in type specific equality predicates Date: Sun, 3 Apr 2011 21:43:54 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1301863451 22231 80.91.229.12 (3 Apr 2011 20:44:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 3 Apr 2011 20:44:11 +0000 (UTC) To: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Apr 03 22:44:07 2011 Return-path: Envelope-to: guile-bugs@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 1Q6U9W-0005Pk-VR for guile-bugs@m.gmane.org; Sun, 03 Apr 2011 22:44:07 +0200 Original-Received: from localhost ([127.0.0.1]:49425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6U9W-0007H7-IZ for guile-bugs@m.gmane.org; Sun, 03 Apr 2011 16:44:06 -0400 Original-Received: from [140.186.70.92] (port=50060 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6U9N-0007GB-4E for bug-guile@gnu.org; Sun, 03 Apr 2011 16:43:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6U9M-0005OC-78 for bug-guile@gnu.org; Sun, 03 Apr 2011 16:43:56 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:65439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6U9M-0005O6-0x for bug-guile@gnu.org; Sun, 03 Apr 2011 16:43:56 -0400 Original-Received: by iwg8 with SMTP id 8so6770501iwg.0 for ; Sun, 03 Apr 2011 13:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=S1nyrAO7F2v0q+4ME5zQ9R3FgVP4XLP9YoQTYL2GVME=; b=UDNkVVZpxG7bN0JqmPJ5dYwzk3AyWV7GF4u0lM4QY7f3jdVswrGp4C3ayht/rMXmTq GA6UVVT0we/1FabE9okQwJr835BQ2TBgNDfJAYrHmBmtci+HN21sN7QK77YcoQWfoQHP OgK47MroXXM/rsNNVEcVmSINWkndhoO22YsmU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=hCvKVTdSfNa3N3s43if0jyuw4zQ1KjqgO0BVyY8aiaMjf3/cjtbg0pINR5III6WVPj tzeZGLwoHwE2OdEP/JqmY0ZSOIWpikpLyjx7EP/0QewGGpTObuRzA29CRGxhZowlEMKB bPiA0RVoEkyMF1vXZpB4gBgtfxKnpp+w7JS68= Original-Received: by 10.231.171.205 with SMTP id i13mr6527330ibz.181.1301863434629; Sun, 03 Apr 2011 13:43:54 -0700 (PDT) Original-Received: by 10.231.19.73 with HTTP; Sun, 3 Apr 2011 13:43:54 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.169 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5418 Archived-At: Hello, Guilers When using type specific equality predicates in guile, I've noticed that they only test the type of an argument, if it has not already decided that the answer is false. Working my way through all the predicates given by the meta command ",a =\??$" we find GNU Guile 2.0.0.147-e309f Copyright (C) 1995-2011 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (= 9 10 "foo") $1 = #f scheme@(guile-user)> (char-set<= char-set:letter char-set:digit "foo") $2 = #f scheme@(guile-user)> (char-set= char-set:letter char-set:digit "foo") $3 = #f scheme@(guile-user)> (string-ci>=? "bar" "foo" '(#\f #\o #\o)) $4 = #f scheme@(guile-user)> (string-ci<=? "foo" "bar" '(#\f #\o #\o)) $5 = #f scheme@(guile-user)> (string>=? "bar" "foo" '(f o o)) $6 = #f scheme@(guile-user)> (string<=? "foo" "bar" '(f o o)) $7 = #f scheme@(guile-user)> (string-ci=? "foo" "bar" '(f o o)) $8 = #f scheme@(guile-user)> (string=? "foo" "bar" '(f o o)) $9 = #f scheme@(guile-user)> (char-ci>=? #\b #\f "foo") $10 = #f scheme@(guile-user)> (char-ci<=? #\f #\b "foo") $11 = #f scheme@(guile-user)> (char-ci=? #\f #\b "foo") $12 = #f scheme@(guile-user)> (char>=? #\b #\f "foo") $13 = #f scheme@(guile-user)> (char<=? #\f #\b "foo") $14 = #f scheme@(guile-user)> (char=? #\f #\b "foo") $15 = #f scheme@(guile-user)> (>= 9 10 "foo") $16 = #f scheme@(guile-user)> (<= 10 9 "foo") $17 = #f ... and so on. I have not checked all of Guile's included modules, but I suspect this is the case for most of them (certainly it is true for boolean=? and symbol=? from (rnrs base) ). Certain predicates do not have this problem because their third argument is expected to be an integer (string-ci<=, string-ci>=, string=, string>=, string<=, string-ci=) and others are restricted to an arity of two (free-identifier=?, bound-identifier=?). I was not sure whether or not to report this, as the behaviour is VERY consistent and therefore, I thought, likely to have been a conscious design choice. If this is the case, you can ignore this, but it seems to me that the reason for having type specific equality predicates is because 1. I want the guarantee or 2. It could theoretically help the bytecode compiler give better code. This is similar to the situation with fixnum and flonum arithmetic functions. If it is not, then we have some low hanging fruit for wannabe guile contributors ;) Regards, Ian