From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111740 invoked by alias); 1 Feb 2017 23:12:50 -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 111723 invoked by uid 89); 1 Feb 2017 23:12:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=BAYES_50,KAM_INFOUSMEBIZ autolearn=no version=3.3.2 spammy=H*M:info, HX-OutGoing-Spam-Status:score, H*r:sk:kawa@so, Hx-spam-relays-external:0.0.0.0 X-HELO: crab.birch.relay.mailchannels.net Received: from crab.birch.relay.mailchannels.net (HELO crab.birch.relay.mailchannels.net) (23.83.209.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Feb 2017 23:12:39 +0000 X-Sender-Id: hostpapa|x-authuser|peter@peterlane.info Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 742B41832D5 for ; Wed, 1 Feb 2017 23:12:37 +0000 (UTC) Received: from hp114.hostpapa.com (unknown [100.96.16.128]) by relay.mailchannels.net (Postfix) with ESMTPA id 982031802B4 for ; Wed, 1 Feb 2017 23:12:36 +0000 (UTC) X-Sender-Id: hostpapa|x-authuser|peter@peterlane.info Received: from hp114.hostpapa.com (hp114.hostpapa.com [172.20.66.218]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.14); Wed, 01 Feb 2017 23:12:37 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: hostpapa|x-authuser|peter@peterlane.info X-MailChannels-Auth-Id: hostpapa X-MC-Loop-Signature: 1485990756837:3304493655 X-MC-Ingress-Time: 1485990756837 Received: from host86-173-178-92.range86-173.btcentralplus.com ([86.173.178.92]:40600 helo=[192.168.1.64]) by hp114.hostpapa.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cZ44n-003MFd-8L for kawa@sourceware.org; Wed, 01 Feb 2017 23:12:34 +0000 To: kawa@sourceware.org From: Peter Lane Subject: building int[] arrays at runtime Message-ID: <3c2d47e1-5cff-cc8b-c250-9924c36861fb@peterlane.info> Date: Wed, 01 Feb 2017 23:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-OutGoing-Spam-Status: No, score=0.6 X-AuthUser: peter@peterlane.info X-IsSubscribed: yes X-SW-Source: 2017-q1/txt/msg00042.txt.bz2 Hi list, I've been using Kawa as an R7RS implementation for a little while, and now am using Kawa to work with a Java library. I've hit a little irritant when calling overloaded methods in Java. If I build an int[] at runtime, I get a warning about more than one applicable method. The code seems to run and give the right result, so the runtime does the right thing. As the warning always appears first, when the script is loaded, I assume the script is compiled on loading and so the problem is discovered. I understand why I'm getting this warning, but wondered if: a. I should do something other than (apply int[] (list 3)) to create an int[] at runtime b. Can I put a compile-time type hint in, to appease/suppress the initial checks? I can turn the warnings off with: --warn-invoke-unknown-method=no but that hides other potential problems, like a mis-spelt method name, until they trip a runtime exception. Below is a simple example of what I'm doing: Java class ---- public class Class1 { public void show (int[] x) { System.out.println ("show " + x[0]); } public void show (String s) { System.out.println ("show " + s); } } ---- Kawa script ---- (define *x* (Class1:new)) (*x*:show "me") (*x*:show (int[] 3)) ---- and all is fine, I get the expected output: $ kawa test.scm show me show 3 The problem arises when I try building the array at runtime: ---- (define *x* (Class1:new)) (*x*:show "me") (*x*:show (apply int[] (list 3))); <----- built at runtime ---- $ kawa test.scm test.scm:3:1: warning - more than one possibly applicable method 'show' in Class1 candidate: void Class1.show(String) candidate: void Class1.show(int[]) show me show 3 thanks, Peter. -- Peter Lane http://peterlane.info/scheme.html