From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102075 invoked by alias); 16 Dec 2019 00:59:37 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 102064 invoked by uid 89); 16 Dec 2019 00:59:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=deciding, H*r:4.86_2 X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Dec 2019 00:59:35 +0000 Received: from [10.9.9.202] (helo=mailfront20.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1igejS-0001Yp-UQ; Mon, 16 Dec 2019 01:59:31 +0100 Received: by mailfront20.runbox with esmtpsa [Authenticated alias (524175)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1igej9-0001f5-Fj; Mon, 16 Dec 2019 01:59:11 +0100 Subject: Re: questions on libraries, pattern matching etc To: Ben , kawa@sourceware.org References: <04256eab-fe24-417b-9f0d-fc554c9add96@www.fastmail.com> From: Per Bothner Message-ID: Date: Mon, 16 Dec 2019 00:59:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <04256eab-fe24-417b-9f0d-fc554c9add96@www.fastmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-q4/txt/msg00010.txt.bz2 On 12/15/19 3:46 PM, Ben wrote: > hi > I'd like to test how I can use pattern match in Kawa. First I did try to use Kawas pattern matching function, but from what I saw it is a bit limited, for example there is no matching of lists. Actually, there is matching of lists, but by matching them as general sequences: #|kawa:1|# (! [a b c @rest] [1 2 3 4 5 6]) #|kawa:2|# (format "a: ~a b: ~a c: ~a rest: ~a~%" a b c rest) a: 1 b: 2 c: 3 rest: #(4 5 6) Implementing more general matching is mainly an issue of design including deciding on a syntax. Fundamentally, should be syntax for matching a pair be: (! (pat_car . pat_cdr) value) or: (! (cons pat_car pat_cdr) value) or something else? The latter is used in Racket, and is more flexible, I believe, but not as elegant - which ties back to fundamental awkwardness with the Scheme evaluation model. Of course once we/I decide on a syntax, then it needs to be implemented, but should be fairly straight-forward, given the existing framework. -- --Per Bothner per@bothner.com http://per.bothner.com/