From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from black.elm.relay.mailchannels.net (black.elm.relay.mailchannels.net [23.83.212.19]) by sourceware.org (Postfix) with ESMTPS id B2AAD386F83F for ; Sat, 4 Jul 2020 04:29:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B2AAD386F83F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eip10.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=chaw@eip10.org X-Sender-Id: dreamhost|x-authsender|chaw@eip10.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 33F38701200; Sat, 4 Jul 2020 04:29:36 +0000 (UTC) Received: from pdx1-sub0-mail-a91.g.dreamhost.com (100-96-23-5.trex.outbound.svc.cluster.local [100.96.23.5]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 7E6D4701292; Sat, 4 Jul 2020 04:29:35 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|chaw@eip10.org Received: from pdx1-sub0-mail-a91.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.8); Sat, 04 Jul 2020 04:29:36 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|chaw@eip10.org X-MailChannels-Auth-Id: dreamhost X-Minister-Slimy: 17e135192c9f8d51_1593836976002_3585523519 X-MC-Loop-Signature: 1593836976002:3697959047 X-MC-Ingress-Time: 1593836976002 Received: from pdx1-sub0-mail-a91.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a91.g.dreamhost.com (Postfix) with ESMTP id 1324FB4EFA; Fri, 3 Jul 2020 21:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=eip10.org; h=to:cc:subject :from:reply-to:in-reply-to:mime-version:content-type:content-id :date:message-id; s=eip10.org; bh=M1AcDCA/3TshHS5fE+g6Docngzg=; b= VDr9UTPem9a4xRyTP9ZqMh3g8evbnjGP7VQmC1+C/cxr+7dTxE+Ov/rMrYNSM8V1 vdgLNJWXRvvHGQeElDkV4jCyXdjn/L56kuu5Ehna/Dyk9LigU8M/7QhWhQYE5GhF Bn/BXumgkTVlZ6RKR3EJfPkcldVeY4aaXD8GWKJH8Xw= Received: from vpaur.eip10.org (cpe-74-75-233-46.maine.res.rr.com [74.75.233.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: chaw@eip10.org) by pdx1-sub0-mail-a91.g.dreamhost.com (Postfix) with ESMTPSA id E0C86B4F13; Fri, 3 Jul 2020 21:29:33 -0700 (PDT) Received: from chaw by vpaur.eip10.org with local (Exim 4.89) (envelope-from ) id 1jrZnv-0003Q5-HT; Sat, 04 Jul 2020 00:29:31 -0400 To: Duncan Mak cc: Jamison Hope , "kawa@sourceware.org" Subject: Re: Working with string keys in a java.util.Map X-DH-BACKEND: pdx1-sub0-mail-a91 From: "Sudarshan S Chawathe" Reply-To: "Sudarshan S Chawathe" In-reply-to: Your message of "Sat, 04 Jul 2020 00:04:39 -0400." X-Mailer: MH-E 8.5; nmh 1.6; GNU Emacs 24.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13147.1593836971.1@localhost> Date: Sat, 04 Jul 2020 00:29:31 -0400 Message-ID: <13148.1593836971@localhost> X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrtdejgdekfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefvuffhrhgjofggtgffkfesthdtredtredtvdenucfhrhhomhepfdfuuhgurghrshhhrghnucfuucevhhgrfigrthhhvgdfuceotghhrgifsegvihhpuddtrdhorhhgqeenucggtffrrghtthgvrhhnpeeliefgffejleelkeehtdelfedtfeefudfffeekleevkeettdevfeehffeuudduhfenucffohhmrghinhepuhhtihhlrdhmrghppdhstggrlhgrqdhlrghnghdrohhrghdpphhrrggtthhitggrlhdqshgthhgvmhgvrdhnvghtpdgsohhthhhnvghrrdgtohhmnecukfhppeejgedrjeehrddvfeefrdegieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehvphgruhhrrdgvihhpuddtrdhorhhgpdhinhgvthepjeegrdejhedrvdeffedrgeeipdhrvghtuhhrnhdqphgrthhhpedfufhuuggrrhhshhgrnhcuufcuvehhrgifrghthhgvfdcuoegthhgrfiesvghiphdutddrohhrgheqpdhmrghilhhfrhhomheptghhrgifsegvihhpuddtrdhorhhgpdhnrhgtphhtthhopehkrgifrgesshhouhhrtggvfigrrhgvrdhorhhg X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 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:29:39 -0000 This is only my personal preference but, for what it's worth, I prefer not having special syntax for such things. I think my earlier message may have inadvertently suggested that I thought having to write (String "foo") to get a Java String is a burden; in reality I think it is quite reasonable. What I often do is define interface procedures between my code and whatever Java library I am using and declare the arguments of those procedures with type annotations (String, in this case) and then Kawa takes care of the conversion from Kawa string to Java String when I invoke the procedure. And Kawa's type checking is handy in catching my errors too, as an added benefit. Regards, -chaw > Date: Sat, 4 Jul 2020 00:04:39 -0400 > Subject: Re: Working with string keys in a java.util.Map > To: Jamison Hope > From: Duncan Mak via Kawa > Reply-To: Duncan Mak > Cc: "kawa@sourceware.org" > > 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. > >