From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 9C3ED3842402 for ; Sat, 4 Jul 2020 04:08:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C3ED3842402 Received: by mail-lf1-x134.google.com with SMTP id g2so19617405lfb.0 for ; Fri, 03 Jul 2020 21:08:21 -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=SzLF0VJEiUOkAdlif2omrp+AANNcI/kQIvuFJvLieXI=; b=JCkJ4J5VBZ9hFNb1P1fmzSn33GK+SaQALzWlkbCD9sr+pEMiBrLUI1Og/J0JDjj2Kg iGBAQwABNS/FX+EaSHtceAZY8DE1UEo/o8HrH9m5FalQd1NtzJRwkIRZyhWXGcv7Kkzf Q4mxFcwWHwmhpHdwfGo82jIi1h4EPdI/8xm11I+pXfWJbZ4qNoqvc1No0RKHMCBN9nSq KHqJ3NUX94p1U6vTlFaTYIITOyzA8ZO84zFhRYHN9XX6YhCOFutiMSMOb0foEQnHvX38 vDZSxHVJIB+WxBgPoZfqZLhGz/z+JO0dSUk3LJvGoO7w32XgOhdl4l8er6AWkF4OW8Gr yrNg== X-Gm-Message-State: AOAM5308e9MWpzdWvOR59OKk0KjoDy+8AbelBy3bPdA9O86bIrgQcofm 2v7aHFsKLUEpohmdVVG+rHUis1g/dnnYjz1ajtAUF7hS X-Google-Smtp-Source: ABdhPJwhMYder6INUveeZD5n9H8rRf6sn+EC90yx7Rmc9o33WP6vKdA3B7Lge8RPCG6afryGCm7BMqAjD/GyMTvIr08= X-Received: by 2002:a19:ad41:: with SMTP id s1mr7718438lfd.191.1593835700283; Fri, 03 Jul 2020 21:08:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Duncan Mak Date: Sat, 4 Jul 2020 00:07:44 -0400 Message-ID: Subject: Re: Extending functional call syntax for Sequences to include Maps To: Per Bothner Cc: kawa mailing list X-Spam-Status: No, score=-2.9 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:08:23 -0000 I think with an optional keyword argument, this could look quite nice! (aMap "key" default: "default value") The keyword could be 'default', or even 'or'. (aMap 'key or: "empty") On Fri, Jul 3, 2020 at 6:05 PM Per Bothner 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) =E2=87=92 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) ; =E2=87=92 "Joe" > > ({:age 42 :name "Joe"} :age) ; =E2=87=92 42 > > ({:age 42 :name "Joe"} :unknown) ; =E2=87=92 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/ > --=20 Duncan.