From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) by sourceware.org (Postfix) with ESMTPS id 954073851C09 for ; Sat, 4 Jul 2020 01:31:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 954073851C09 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=alum.mit.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=j.r.hope@gmail.com Received: by mail-vs1-f50.google.com with SMTP id f24so17930581vsg.1 for ; Fri, 03 Jul 2020 18:31:10 -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:references:in-reply-to:from:date :message-id:subject:to; bh=fdgzXCN6/GMf92OcO/lKqDzBPQmA/F2C9ZIljkB7yxU=; b=DwQZ74uVI6xSCJ0iKe4uLJdfhEFNQ9PfZnlExjR57EQRTXvQ7yRXMs1w1YpYMKaIlM xpj1ihxavIbteNHLmPHkiAzl/3GI7x4X7pqtIyboUE3FvoxwX0b3dWisIeNJ8guoGzGW 4DvP8SD3e20cjS5yGcd7jcAuLogrD2BnrRiRhR57xjSksBLted7tQUc3fycGVy33/EhM 7jrG+mAb4i+wA0dut8UOVtN49FT9Um7Lgt7CkboXLd/oQIA8EIWtiXCl/H/ctEWnNBCE mJ648fxyuWWv09/pgqURjmCXHy7UA9Z440wQGUfWZbGaNHTmJ+7Cq07iTZ5QugRLBzE5 VnCQ== X-Gm-Message-State: AOAM530zc7BktTOYMiWECrtGW+4e1NibrMaF+E3CKpGRJxR8bLuAtfEr DzR9BoloVPE9V8o1ndDxB4hZFwHjnH+5vd2ilHPe0g== X-Google-Smtp-Source: ABdhPJx9FaIPrq5HNp3J+lo9+e1udMD/6Q0XnYQlGsExzCYvYKgIpFsuqUGfqVFuVukAFqW/iztHPcmVUPB1dyzDkqM= X-Received: by 2002:a67:fac7:: with SMTP id g7mr28450898vsq.10.1593826269919; Fri, 03 Jul 2020 18:31:09 -0700 (PDT) MIME-Version: 1.0 References: <31504.1593813177@localhost> <68f1a45a-173d-aa66-298e-599c37cd93dc@bothner.com> In-Reply-To: <68f1a45a-173d-aa66-298e-599c37cd93dc@bothner.com> From: Jamison Hope Date: Fri, 3 Jul 2020 21:30:59 -0400 Message-ID: Subject: Re: Working with string keys in a java.util.Map To: "kawa@sourceware.org" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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" Content-Transfer-Encoding: quoted-printable 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: Sat, 04 Jul 2020 01:31:14 -0000 In this case, I think another option is to define a wrapper function that specifies the argument type as String, like: (define (get attrs key::String) (attrs:get key)) Then (get attrs =E2=80=9Cowner=E2=80=9D) ought to work with the literal con= verted to java.lang.String. -J On Fri, Jul 3, 2020 at 6:33 PM Per Bothner wrote: > On 7/3/20 2:52 PM, Sudarshan S Chawathe wrote: > > I've had to get Java "String"s from Kawa strings often for similar > > reasons when using other JVM libraries, etc., and I have just used > > '(String "kawa string)'; it seems to work well, although it does > > introduce clutter. > > I don't see how to avoid that in general. One could write a wrapper Map > that uses a coercion function to convert the key to required type, > similar to the coercion function in the make-parameter function. > > Another way is to call the toString method, since Kawa strings > implement java.lang.CharSequence: > ("kstring":toString) > > This is cheap if the Kawa string is an IString, since uses a > java.lang.String. > > Alternative syntax: > > (->java.lang.String "kstring") > or shorter: > (->String "kstring") > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ > --=20 Jamison Hope