From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 13DD6387084D for ; Mon, 22 Jun 2020 16:26:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 13DD6387084D Received: by mail-lj1-x229.google.com with SMTP id a9so20021357ljn.6 for ; Mon, 22 Jun 2020 09:26:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ew5VMxrVr2fmaOgqxcFpwRAQekAkRf52pygsetNvI2U=; b=LzSzhMaItATED1mz7/Oq1bEXGd94RsJh4zhdpsRQUdXd8dBCG8+9KCf018g3EuUupP v+X0jOT5fHjIRXsEPVyoMmYJpsaVwswEj3ZYQ2rKUBqgzXrafU/9Z07u4OGuJQexNHpH C2qY5dd2B6hMD3cC7KHevmd+RgclkoxXLtrDxRpnqy7Wylgv10R3pNuICcNlUATlMVRC tbzv4xgb6lpzfPTqLdSSFfOE5muu7g0/5N/GNZvWenyOnmfKnidFKsMTp/Ok4X1XpeM0 31BhlcrZ6CrD2fbRO3MUtZZJcTCgibqedNXsrK6IIC1FdRehNo6/c7n7KqDEky44q3gW jJDQ== X-Gm-Message-State: AOAM533r+osTzTS2QGyPQvMit7GiofuA2OXxjXA9kn5PfB+Wun3O8phB jC/IBL6kLprR5WdThzwC6N9yddCEe0m31NfTwTxaD/fYi6o= X-Google-Smtp-Source: ABdhPJwkF3JbSqNEPQjPA2nRaCQLSiYMBOcXcYYQt7obXLVmod56bJsLJzRKrK5sBwONQBYRyFkTaV46bSyq5Sw97NU= X-Received: by 2002:a05:651c:2cc:: with SMTP id f12mr8632314ljo.329.1592843202114; Mon, 22 Jun 2020 09:26:42 -0700 (PDT) MIME-Version: 1.0 From: Duncan Mak Date: Mon, 22 Jun 2020 12:26:05 -0400 Message-ID: Subject: Going from Scheme list to Java array To: kawa mailing list X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2020 16:26:45 -0000 Hello, it doesn't look like there's a Scheme list -> Java array conversion function, so I tried to write one modelled after the function from Clojure: (define (into-array l ::java.util.List array-type) (let* ((size (length l)) (array ((primitive-array-new array-type) size))) (l:toArray array))) (display (into-array (list 1 2 3) )) When I run this in Kawa 3.1.1, this is what I see: foo.scm:4:5: warning - more than one possibly applicable method 'toArray' in java.util.List candidate: Type java.lang.Object[] java.util.List.toArray(ClassType java.util.function.IntFunction) candidate: Type java.lang.Object[] java.util.List.toArray(java.lang.Object[]) Argument (null) to 'gnu.lists.Pair.toArray' has wrong type at gnu.mapping.CallContext.matchError(CallContext.java:185) at gnu.expr.GenericProc.applyToConsumerGP(GenericProc.java:132) at gnu.mapping.CallContext.runUntilDone(CallContext.java:586) at gnu.mapping.CallContext.runUntilValue(CallContext.java:669) at gnu.mapping.Procedure.applyL(Procedure.java:136) at gnu.kawa.reflect.Invoke.applyToObject(Invoke.java:198) at gnu.mapping.CallContext.runUntilValue(CallContext.java:656) at gnu.mapping.Procedure.apply3(Procedure.java:167) at foo.intoArray(foo.scm:4) at foo.intoArray$check(foo.scm:1) at gnu.mapping.CallContext.runUntilValue(CallContext.java:656) at gnu.mapping.Procedure.apply2(Procedure.java:160) at foo.run(foo.scm:6) at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:290) at gnu.expr.CompiledModule.evalModule(CompiledModule.java:42) at gnu.expr.CompiledModule.evalModule(CompiledModule.java:60) at kawa.Shell.runFile(Shell.java:571) at kawa.Shell.runFileOrClass(Shell.java:474) at kawa.repl.processArgs(repl.java:710) at kawa.repl.main(repl.java:830) Is there a better way to write this? What's the right way to do this conversion and should we include it into the system? -- Duncan.