From: Per Bothner <per@bothner.com>
To: Duncan Mak <duncanmak@gmail.com>,
kawa mailing list <kawa@sourceware.org>
Subject: Re: Extending functional call syntax for Sequences to include Maps
Date: Fri, 3 Jul 2020 15:05:30 -0700 [thread overview]
Message-ID: <b5d0a614-e40a-4728-6c9b-4989ee08d9a8@bothner.com> (raw)
In-Reply-To: <CABgWrqoRXb3_swr5hX5J-Vdy8j-MVWVxHLLdJcYtApQqu0=7=w@mail.gmail.com>
On 7/3/20 2:24 PM, Duncan Mak via Kawa wrote:
> More concisely, you can use (Kawa-specific) function call syntax:
>
> (vec1 3) ⇒ 8
>
>
> I was a little disappointed when I found out that this doesn't work for
> Maps, which is also something Clojure allows [0]:
>
> ;; This is Clojure not Scheme
>
> ({:age 42 :name "Joe"} :name) ; ⇒ "Joe"
> ({:age 42 :name "Joe"} :age) ; ⇒ 42
> ({:age 42 :name "Joe"} :unknown) ; ⇒ nil
I vaguely remember discussing this some years ago, and I think the main
(conceptual) problem is how to handle arguments with no binding, i.e.
the 3rd case above. By analogy with sequences, it should throw an
exception - which may not be the most convenient
I mentioned a couple of possible approaches, but I don't recall
what they were. I think I was leaning towards a way to specify
a default value - and throw an exception when no default was specified.
I haven't been able to find that email, so far.
A possibly solution:
(htab key [default])
If there is no entry for key in htab, then default is returned
if specified; otherwise an exception is thrown.
You should also be able to do:
(set! (htab key) new-value)
--
--Per Bothner
per@bothner.com http://per.bothner.com/
next prev parent reply other threads:[~2020-07-03 22:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 21:24 Duncan Mak
2020-07-03 22:05 ` Per Bothner [this message]
2020-07-04 4:07 ` Duncan Mak
2020-07-15 18:44 ` Jamison Hope
2020-07-16 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5d0a614-e40a-4728-6c9b-4989ee08d9a8@bothner.com \
--to=per@bothner.com \
--cc=duncanmak@gmail.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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).