From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id A26073842402 for ; Sat, 4 Jul 2020 04:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A26073842402 Received: by mail-lf1-x129.google.com with SMTP id t74so19619097lff.2 for ; Fri, 03 Jul 2020 21:05:17 -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:cc; bh=Ew8t0Gyi83B9aD3FiaQZMjceLvw+xeEDN3E0z43yHHg=; b=XEK06axxA8X6E2eJgIXVaQFrYKa/YaGh/ZJ6P509BVmn4TFHtqdrm5Z9wY/BFhsvFU ZjyrKKIHTJkfVH0ry+IBA9DR53v9+C7QC5kPqhdr3y7JQ+IznR7UKE5SPbq/M2gXeiid kjN8edEyBBbNUJFAF82bBpIYP2SDEshPp8rCRrxg83Ig/fIg2/uyNMjYbAB+oMlg7M+l n/fOhz3OfPYEzfrpixUlsRNpZf8ErRIe+gFxlooN4MfuRYYAB66PYyt2UjyVjvNbXHrm pgLHN0K/YjuIGIC0QNczxUKLnimyoqjZXKwWvBocnolw8AsmVAwSMhNhWqZmvrGTRCDl 49Fw== X-Gm-Message-State: AOAM5330gvsvbo/6GY/aVofrwq7qAk09s+xGssQiGa3n+hVHuZqNeqqn Ox9Q4x8jSNXC9CgHKLmRJqMykyvmfYE07EYFK+U= X-Google-Smtp-Source: ABdhPJz7oHo6LdYahTyp4pl0hpVCquHt95OxwHwAwxrZqMZQbxefKYT780MIVbWRYrrD7bzeZ470ojQAxXsCBjg0yj0= X-Received: by 2002:ac2:4241:: with SMTP id m1mr24204945lfl.20.1593835516057; Fri, 03 Jul 2020 21:05:16 -0700 (PDT) MIME-Version: 1.0 References: <31504.1593813177@localhost> <68f1a45a-173d-aa66-298e-599c37cd93dc@bothner.com> In-Reply-To: From: Duncan Mak Date: Sat, 4 Jul 2020 00:04:39 -0400 Message-ID: Subject: Re: Working with string keys in a java.util.Map To: Jamison Hope Cc: "kawa@sourceware.org" X-Spam-Status: No, score=-4.3 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" 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 04:05:19 -0000 What do you think of having literal syntax for this -- what about $"this is a java string"? This is kinda inspired by what Scala did a little while again: https://docs.scala-lang.org/overviews/core/string-interpolation.html Looks like Gauche decided to do something similar: https://practical-scheme.net/gauche/man/gauche-refe/Strings.html#String-int= erpolation Gauche's design look quite nice: #"This is Gauche, version ~(gauche-version)." =E2=87=92 "This is Gauche, version 0.9.9." On Fri, Jul 3, 2020 at 9:31 PM Jamison Hope wrote: > 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 c= onverted 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 Ma= p > > 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/ > > > -- > Jamison Hope > --=20 Duncan.