From: Jamison Hope <jhope@alum.mit.edu>
To: kawa mailing list <kawa@sourceware.org>
Subject: Re: Extending functional call syntax for Sequences to include Maps
Date: Wed, 15 Jul 2020 14:44:21 -0400 [thread overview]
Message-ID: <CA+ghDQ8z=DeykLszLY3LeoSmXvKZ+VpWDU7UKWAOf4YCPNEATQ@mail.gmail.com> (raw)
In-Reply-To: <b5d0a614-e40a-4728-6c9b-4989ee08d9a8@bothner.com>
On Fri, Jul 3, 2020 at 6:05 PM Per Bothner <per@bothner.com> wrote:
>
> 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.
I suspect you're remembering this conversation we had five (!) years ago:
https://sourceware.org/pipermail/kawa/2015q1/006284.html
You were leaning toward throwing an exception on no-default, and I was
leaning toward returning #!null for simplicity/consistency with Java,
and also because #!null is treated as false, which is like what
assq/assv/assoc and memq/memv/member return for an absent key.
-J
>
> 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/
--
Jamison Hope
next prev parent reply other threads:[~2020-07-15 18:44 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
2020-07-04 4:07 ` Duncan Mak
2020-07-15 18:44 ` Jamison Hope [this message]
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='CA+ghDQ8z=DeykLszLY3LeoSmXvKZ+VpWDU7UKWAOf4YCPNEATQ@mail.gmail.com' \
--to=jhope@alum.mit.edu \
--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).