From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 6F6EB3858D37 for ; Tue, 30 Jun 2020 04:39:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6F6EB3858D37 Received: by mail-lj1-x22b.google.com with SMTP id q7so7623409ljm.1 for ; Mon, 29 Jun 2020 21:39:12 -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=muZ64xjCEySEisNAEgbWNAC1t4N2oggOmd1No0IPUXw=; b=lGFSAaS6IJjGmH4sFRAxu+KSROng+3Mk1PcpZdd3giv+jchWpKOzGOBHweCWzpapZo AxlR+mPTDjeYmG34eBOgorqTDMPtjGkeBLwBZ309Qh7EL7+OWc1TAZB7eeyjgDVrPgdC owKCXtGqL0O9YQlbSR4Smp6sf4zxayTMTc+jv8SkySv51cQjf0F64shxNeJppivRZ8Np IBQGOLIOCQczGXNzdi21cYONRQFE8shiE87HEu+AQBYSUNfI6aDa8mE7bn2JvoZTbFMr bisVLwYhjyUTluJMWrYIX8I/YHZL9OhKxpCxfRdj4dM2onv7wZvZabfosNS0q26sMcKi F39g== X-Gm-Message-State: AOAM532hqLI7jXD4V73j0qJ3JcIEjSqJ022AQ8EOsdpU9n86zQ0A4n1l KlUVgZWEN77BqII58uNgFKOZ+2W4NZnBGjxGUz5nQoDKWcU= X-Google-Smtp-Source: ABdhPJzFMLlMX2IRzLYxSP2QvEoePZxDSxR8IXhdblCnIh97HhvwRSW95tqIN2HdPyTlJO4Yu82ivTAd5ffS2Fq4Sso= X-Received: by 2002:a2e:9908:: with SMTP id v8mr5479917lji.186.1593491951136; Mon, 29 Jun 2020 21:39:11 -0700 (PDT) MIME-Version: 1.0 References: <04256eab-fe24-417b-9f0d-fc554c9add96@www.fastmail.com> <81eb9fce-930a-f2b7-52ce-12f8da4c0be4@bothner.com> In-Reply-To: <81eb9fce-930a-f2b7-52ce-12f8da4c0be4@bothner.com> From: Duncan Mak Date: Tue, 30 Jun 2020 00:38:34 -0400 Message-ID: Subject: Re: questions on libraries, pattern matching etc To: Per Bothner Cc: kawa mailing list X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, 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" 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: Tue, 30 Jun 2020 04:39:14 -0000 Hello Per, So I'm trying to really learn the Kawa pattern language, but I couldn't figure out how to match a literal. While it was encouraging to see that this seems to work: #|kawa:17|# (match '(foo 1 2) ([foo a b] (+ a b))) 3 But not this: #|kawa:18|# (match '(foo 1 2) (['foo a b] (+ a b))) java.lang.NullPointerException So how do I match against a form like '(foo x y) and make sure that the first element of the list is the literal symbol 'foo? Also, this is more akin to destructuring, but is there a way to use the match macro against a record? Thanks! Duncan. On Mon, Jun 29, 2020 at 5:50 PM Per Bothner wrote: > On 6/29/20 1:50 PM, Duncan Mak wrote: > > Hello Per, > > > > About the syntax for a match macro, work on SRFI 200 (draft) just > started: > > > > https://srfi.schemers.org/srfi-200/srfi-200.html > > I haven't read it in detail, but it looks like the proposed pattern syntax > is more-or-less compatible with Kawa. > > (There are lots of SRFIs coming out, and I've given up trying to pay close > attention, especially since may of them are philosophically incompatible > with Kawa. For example, Kawa has a consistent and powerful "sequence" > concept and I think it's a mistake to define a large library of procedures > for every sequence type, as seems to be the direction of R7RS-large.) > > The key thing about patterns in Kawa is they are integrated in the > standard syntax forms, rather than being a pure "add-on" library feature. > For example, the "variable" defined in a LET form can be a pattern. > > Also, not that in Kawa patterns and type-specifiers are integrated: a > PATTERN > can be: > PATTERN ::TYPE > > To extend the syntax of Kawa patterns (which is highly deirable, > and could plausible be done in the style of SRFI-200) one would need > to extend kawa/lang/BindDecls.java, primarily. > Not completely trivial, but not impossible either :-) > > > What do you think about adopting the syntax for the > Wright-Cartwright-Shinn matcher? > > > > I've been trying to use match.scm (and its variants) in Kawa and simple > patterns kinda work, but I see that: > > > > - matching records > > - matching quasiquotes > > > > These two parts don't seem to be working. > > > > For now, I've backed out of using match.scm due to the missing features, > but it'd really be nice to have a match macro that comes with Kawa scheme, > following one of the grammar listed in the SRFI. > > > > Going a different direction, this design for a CASE* macro is also > interesting, > https://github.com/axch/pattern-case/blob/master/pattern-matching.txt > > While I'm OK with adding verious SRFI libraries for cmpatibility, patterns > in > the core part of Kawa should follow (and extend) the design in: > https://www.gnu.org/software/kawa/Variables-and-Patterns.html#meta-pattern > https://www.gnu.org/software/kawa/Definitions.html > https://www.gnu.org/software/kawa/Local-binding-constructs.html > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ > -- Duncan.