From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25838 invoked by alias); 20 Feb 2015 00:39:07 -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 25828 invoked by uid 89); 20 Feb 2015 00:39:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,T_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; Fri, 20 Feb 2015 00:39:05 +0000 Received: from [10.11.21.74] (unknown [10.11.21.74]) by mail.theptrgroup.com (Postfix) with ESMTPS id 07EDDE082B for ; Thu, 19 Feb 2015 19:39:02 -0500 (EST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: strange int->boolean behavior From: Jamison Hope In-Reply-To: <54E66BD2.1060903@bothner.com> Date: Fri, 20 Feb 2015 00:39:00 -0000 Content-Transfer-Encoding: quoted-printable Message-Id: <0D06BFFE-2807-4BA0-AAC3-5A999DA158B2@theptrgroup.com> References: <72768B2F-733F-4F37-BB02-880E16C2E855@theptrgroup.com> <54E66BD2.1060903@bothner.com> To: "kawa@sourceware.org list" X-IsSubscribed: yes X-SW-Source: 2015-q1/txt/msg00047.txt.bz2 On Feb 19, 2015, at 6:03 PM, Per Bothner wrote: > On 12/18/2014 10:19 AM, Jamison Hope wrote: >> Sometimes, a primitive 0 is false: >>=20 >> #|kawa:1|# (->boolean (->int 3)) >> Exception in thread "main" java.lang.Error: unsupported CodeAttr.emitCon= vert >> at gnu.bytecode.CodeAttr.emitConvert(CodeAttr.java:2006) >> [...] >>=20 >> #|kawa:1|# (if (->int 3) "YES" "NO") >> YES >> #|kawa:2|# (if (->int 0) "YES" "NO") >> YES >> #|kawa:3|# (define (f x::int) ::string (if x "YES" "NO")) >> #|kawa:4|# (f 3) >> YES >> #|kawa:5|# (f 0) >> NO >> #|kawa:6|# (disassemble f) >> In class atInteractiveLevel$3 >>=20 >> Method name:"f" public static Signature: (int)java.lang.CharSequence >> Attribute "Code", length:70, max_stack:1, max_locals:1, code_length:14 >> 0: iload_0 >> 1: ifeq 10 >> 4: getstatic >> 7: goto 13 >> 10: getstatic >> 13: areturn >>=20 >> I get similar results with the other primitive types. If I'm following = things correctly, >> it's ConditionalTarget#compileFromStack which is treating zero as false? >=20 > Yes. I checked in a fix for this. The change in ConditionalTarget depend= s on the language; > specifically whether language.isTrue(Integer.valueOf(0)). If so, we an j= ust > emitGoto the true label. Cool, thanks. > I forgot about or overlooking this message, but found it while searching = for > another discussion That's OK, I've been too busy lately to bug you about it (and you've obviou= sly been busy too, since you've made ~100 commits since then). > (which turn out to be "proposed changes to handling of false > and end-of-list"). >=20 > (I'm looking into doing at least part of that previous proposal - specifi= cally > treating #!null as false.) Great! That will be a welcome change. Wow, that discussion was a while ag= o.. there's some good stuff in there (in my perhaps slightly biased opinion). -- Jamison Hope The PTR Group www.theptrgroup.com