public inbox for
 help / color / mirror / Atom feed
From: Per Bothner <>
Subject: Re: Working with string keys in a java.util.Map
Date: Fri, 3 Jul 2020 15:33:01 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <31504.1593813177@localhost>

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:

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

  reply	other threads:[~2020-07-03 22:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 21:46 Duncan Mak
2020-07-03 21:52 ` Sudarshan S Chawathe
2020-07-03 22:33   ` Per Bothner [this message]
2020-07-04  1:30     ` Jamison Hope
2020-07-04  4:04       ` Duncan Mak
2020-07-04  4:29         ` Sudarshan S Chawathe
2020-07-04  5:24         ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).