From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 9FF153858D28 for ; Tue, 10 Oct 2023 05:33:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FF153858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-533d6a8d6b6so9297706a12.2 for ; Mon, 09 Oct 2023 22:33:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696916000; x=1697520800; darn=sourceware.org; h=content-transfer-encoding:cc:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5wjOtxPlPk5N2/zttND1MD3LxD1hA10+VPLp79k7EZI=; b=fqpJtd3toO6oak4KXVir6PKV8JCHr9wghjIkrjDYkrublYikoI7BSzqXAWutnhXQ4E l1jKmtKpfQmNNww10gUJ4k9QQB+hCudrDTjE1+EXyImL92z7jtCO0C2zp6frjzu/j3m1 T2pzPJ5vJz2kYqQhhOSNFPTct1GG7q/lHdeqmDxP4K3vp4GXKe8Ho6aU8Y45CLHWNA3S Isg+pZcz9SvRIQBb4mK4K1AFdOt/Z+3nAC6KVUoumLM7VH8qHumn1Q0AHxywF4tXKsCf /xnj56XZffCZPg6fxhiuOO9bIiBXJLqetim1cai/tfWv9MQKZLGzvYUkyAiSn1qVNgkb 8M5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696916000; x=1697520800; h=content-transfer-encoding:cc:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5wjOtxPlPk5N2/zttND1MD3LxD1hA10+VPLp79k7EZI=; b=X7hkSwqh2/D9PhbkzrTJHy3zO7URYMDVnxrz4q8Wvc8Qhr0+zsok7vrHQr0+Jn7L4Y JWA16v5/ZpCGvLUO+Q8ozInJz18zZODdmRIio5FuSsYiS6MUGWvhP5Jn5MB4HgUqi88h VamBaplQ7H+3jcb6WT8KHCiClxQVrU+7Jq6+vYTMq3AraAdQgdXzdgAnJtiEetmAwGSo sm9cNtUQjPZ0ZtR4c4fb/llUQ0TN/+hMfrMYsZUQ8nZPXD1kwBOb03QYehFOWVbJNxI4 6/Au0Vr3JkCWyDy5qP9pyA4wybkwb1IPTTo+Qnt4dMQ3nlRrx/MelnefOFOkRSdjr94b v4Ew== X-Gm-Message-State: AOJu0Yz/zlmIq1PlChqgA/qlBqiKk/wiGS/8uWUxAzLX5V8GuehjZxeG E84IdV1USlsHqzrPyMXW4OgGkXWMCc+1ya9HY/UixVU0Dd8= X-Google-Smtp-Source: AGHT+IH6RhiVZYBhKrtWfXI9mzYI85bc5e4TEsWXhdxIvVirFyjP3ORUlDZT86/kwWoQqBYCvs1YmWuJ33zDwmSUumE= X-Received: by 2002:a05:6402:50b:b0:523:18db:e3ab with SMTP id m11-20020a056402050b00b0052318dbe3abmr14159906edv.39.1696915999881; Mon, 09 Oct 2023 22:33:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Damien Mattei Date: Tue, 10 Oct 2023 07:33:08 +0200 Message-ID: Subject: Re: unrecognized pattern operator list Cc: kawa mailing list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MISSING_HEADERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: i use 'match' for Kawa like this in my code, i haven't test it yet but i suppose it is ok ,having done multiple test in the Kawa REPL : (match (list index1-or-keyword-eval-pos index2-or-keyword-eval-pos) ;; {a <+ (make-vector 7 0)} ;; '#(0 0 0 0 0 0 0) ;; > {a[$ $] <- #(1 2 3)} ;; > a ;; '#(1 2 3 0 0 0 0) ;((list (=3D=3D slice) (=3D=3D slice)) ([s1 s2] #!if (and (equal? s1 slice) (equal? s2 slice)) (container-copy! container-eval 0 expr-eval) container-eval ;; returning a value allow the chaining : {T[3 5 6] <- A[4 2 3] <- T[7 2 4]} ) ;; {s <+ (string-append "abcdefgh")} ;; "abcdefgh" ;; > {s[3 $] <- "zob"} ;; > s ;; "abczobgh" ;; > ([i1 s] #!if (equal? s slice) (container-copy! container-eval i1 expr-eval) container-eval ;; returning a value allow the chaining : {T[3 5 6] <- A[4 2 3] <- T[7 2 4]} ) ([s i2] #!if (equal? s slice) (container-copy! container-eval 0 expr-eval 0 i2) container-eval ;; returning a value allow the chaining : {T[3 5 6] <- A[4 2 3] <- T[7 2 4]} ) ([i1 i2] (cond ((vector? container-eval) ;; normal case (function-array-n-dim-set! container-eval expr-eval (reverse (list i1 i2)))) ((array? container-eval) ;;(display "assignment.* : 2 args ,array case : container-eval =3D ") (display container-eval) (newline) (array-set! container-eval index1-or-keyword-eval index2-or-keyword-eval expr-eval)) (else ;; overloaded (define args-lst (list container-eval i1 i2)) (define setter! (find-setter-for-overloaded-square-brackets args-l= st)) (setter! container-eval i1 i2 expr-eval))) expr-eval) ;; returning a value allow the chaining : {T[3 2] <- A[4] <- T[2 4]} ) ;; end match i can not find another way than: #!if (and (equal? s1 slice) (equal? s2 slice) to test equality to '($ $) or (list slice slice) , that does not look like a pattern and i could have use 'cond' instead of 'match' as there is little gain in syntax here. On Mon, Oct 9, 2023 at 11:07=E2=80=AFPM Damien Mattei wrote: > > GRASP ,amazing code , would be wonderful for teaching. > > On Mon, Oct 9, 2023 at 10:26=E2=80=AFPM Panicz Maciej Godek > wrote: > > > > For what it's worth, I wrote my own implementation of match for Kawa an= d use it in GRASP: > > > > https://github.com/panicz/grasp/blob/main/src/language/match.scm > > > > It is derived from the now withdrawn SRFI-200 document that I submitted= at some point: > > > > https://srfi.schemers.org/srfi-200/srfi-200.html > > > > (it contains a fairly detailed description of the implementation of the= match macro, both in syntax-case and syntax-rules) > > > > Anyway, it doesn't seem to be causing any conflicts with Kawa's built-i= n match, so you cloud try adapting it to your taste. > > > > pon., 9 pa=C5=BA 2023 o 22:18 Damien Mattei via Kawa napisa=C5=82(a): > >> > >> one of problem is coming from the special syntax of kawa that use > >> [ ] where others scheme don't and incompatible with SRFI 105, this > >> limits some use. > >> like: in type[] or match with patterns looking like ([_ y] ... > >> this would be a good idea to have an option in Kawa that allow > >> replacing those [ ] by normal ( ) or even be compatible with the 2 > >> syntaxes should be possible > >> > >> in my case i dislike 'match form and do not using typing in scheme > >> when available so this not a big problem in my codes but for now i do > >> not know how to modify the SRFI-105 reader for be compatible. It is > >> also possible to parse it with SRFI 105 and after modify again the > >> code to set back the transformed [] in () again in [] in 'match and > >> type[] .... > >> > >> > >> On Mon, Oct 9, 2023 at 4:48=E2=80=AFPM Damien Mattei wrote: > >> > > >> > hello, > >> > > >> > in this code belonging from Guile and Racket version: > >> > > >> > (match (list index1-or-keyword-eval-pos index2-or-keyword-eval-pos > >> > index3-or-keyword-or-step-eval-pos) > >> > > >> > > >> > > >> > > >> > ;; {a <+ (make-vector 7 0)} > >> > ;; '#(0 0 0 0 0 0 0) > >> > ;; > {a[$ $] <- #(1 2 3)} > >> > ;; > a > >> > ;; '#(1 2 3 0 0 0 0) > >> > ((list (=3D=3D slice) (=3D=3D slice)) > >> > (container-copy! container-eval > >> > 0 > >> > expr-eval) > >> > > >> > i have this error: > >> > unrecognized pattern operator list near ((list (=3D=3D slice) i2 (= =3D=3D slice)) > >> > slice is defined like that: > >> > > >> > (define $ '$) > >> > (define slice $) > >> > > >> > what is the equivalent syntax for kawa? > >> > > >> > damien