From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aibo.runbox.com (aibo.runbox.com [91.220.196.211]) by sourceware.org (Postfix) with ESMTPS id C470A3844079 for ; Fri, 3 Jul 2020 22:05:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C470A3844079 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bothner.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=per@bothner.com Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1jrToa-0001Gb-PN; Sat, 04 Jul 2020 00:05:49 +0200 Received: by submission02.runbox with esmtpsa [Authenticated alias (524175)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1jrToL-0007Pj-RZ; Sat, 04 Jul 2020 00:05:34 +0200 Subject: Re: Extending functional call syntax for Sequences to include Maps To: Duncan Mak , kawa mailing list References: From: Per Bothner Message-ID: Date: Fri, 3 Jul 2020 15:05:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Fri, 03 Jul 2020 22:05:52 -0000 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/