From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30430 invoked by alias); 19 Feb 2020 21:39:39 -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 30421 invoked by uid 89); 19 Feb 2020 21:39:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-1.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=D*com=c2, ben, Ben, Implementing?= X-HELO: mail-lj1-f174.google.com Received: from mail-lj1-f174.google.com (HELO mail-lj1-f174.google.com) (209.85.208.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Feb 2020 21:39:36 +0000 Received: by mail-lj1-f174.google.com with SMTP id o15so1963578ljg.6 for ; Wed, 19 Feb 2020 13:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=epe2nICjwxaCqhWpiO7NW+D3zHV6DT/x3OT+6pn8C10=; b=e9ygIhtvtLHD5Q7F129aceQrEPHR52KmjdTFFlFo45I325ZuWwbTm2qvZxZV1G7Yn3 qQXz9pttmstOr9MGksWTplctI3Ux13uZpPwLY25l3cRKfKnZoXMam7NUAFrVqbJhm2k8 FYUl6w3XmJhB+Ft8J53rsIXn6ykczL6PF2FWizG9skG90bzM6Tg7BPX+pBiRsL07vihf ShACDS5vyYTXdsA/0DgRHNGD6HienPIDylAcr/rA9jYchqgc6DOCYlyLNdgEfyQpvDhE LHCl3vUaRE3egIEvHgmHasD7U7NUVmHMkQb99/+qvurc+F40WgJlrHGasSMoVPU5ajuh Lkpg== MIME-Version: 1.0 References: <04256eab-fe24-417b-9f0d-fc554c9add96@www.fastmail.com> In-Reply-To: From: Duncan Mak Date: Wed, 19 Feb 2020 21:39:00 -0000 Message-ID: Subject: Re: questions on libraries, pattern matching etc To: Per Bothner Cc: Ben , kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2020-q1/txt/msg00019.txt Hello Ben, Did you figure out a way to get a pattern match library to work with Kawa? Which one did you go with? I came across this recently, and I'm gonna give it a try: http://www.j-paine.org/match.html I don't have particularly sophisticated needs, I'm hoping to find something that will let me match on lists with some literals and some open slots, and it'll be great if I can define optional elements also. Duncan. On Sun, Dec 15, 2019 at 7:59 PM Per Bothner wrote: > 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/ > -- Duncan.