Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Wherever you go...There you are. -- Buckaroo Banzai


devel / comp.lang.lisp / destructuring-match - the name of the game

SubjectAuthor
* destructuring-match - the name of the gameMadhu
`* Re: destructuring-match - the name of the gameZyni Moë
 `* Re: destructuring-match - the name of the gameMadhu
  `* Re: destructuring-match - the name of the gameZyni Moë
   `- Re: destructuring-match - the name of the gameMadhu

1
destructuring-match - the name of the game

<m3a67v553n.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17169&group=comp.lang.lisp#17169

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: enometh@net.meer (Madhu)
Newsgroups: comp.lang.lisp
Subject: destructuring-match - the name of the game
Date: Tue, 23 Aug 2022 21:23:16 +0530
Organization: Motzarella
Lines: 57
Message-ID: <m3a67v553n.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="3db4107e10762b9d1354b675301bcc35";
logging-data="3188694"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/H0VYijZJVoKhIij0Sjjz1N7cFd21fTQE="
Cancel-Lock: sha1:q0tAEhjVCwSGO8ZO1/XEnhq+NLE=
sha1:G4gk8GPFX1SFPCo3M3Oi3Fc6RFA=
 by: Madhu - Tue, 23 Aug 2022 15:53 UTC

It looks like tim bradshaw has published a macro called
destructring-match which sounds like destructuring bind but looks more
like elisp's pcase with additional multiple match clauses and additional
(:when ..) syntax. I would disagree with the name, because it doesn't
seem to be analogous to lisp's destructuring

I wanted to post my own destructuring-match macro (which I wrote when
pithy-xml came out.) This has the same surface-syntax as
destructuring-bind i.e. (lambda-list value-form &body body) and it just
expands to a destrucuring-bind form. The difference is it matches
literal elements of value-form directly, (and so it can process
"parameter lists" which are usually passed as the rhs expression to
destructuring-bind)

```
(destructuring-match (:head first-arg 2 &rest rest &key foo bar &allow-other-keys)
;; :head and 2 are matched literally
'(:head 1 2 :foo 10 :bar 20 :xyz 30)
(list foo bar first-arg )) => (10 20 1)
```

I've found it useful in processing sexps (from json or xml sources)
after flattening them, but maybe destructring-match isn't the best name.
Perhaps someone can understand what its doing can suggest a name or
confirm the name.

```
(defmacro destructuring-match (macro-lambda-list value-form &body body)
(let (renamed-bindings declares)
(labels ((remove-declares (code)
(cond ((and (consp (car code)) (eql (caar code) 'declare))
(push (car code) declares)
(remove-declares (cdr code)))
(t code)))
(snarf-bindings (x)
(typecase x
(null)
(cons (case (car x)
((&aux &key &optional &rest &allow-other-keys) x)
(t (cons (snarf-bindings (car x))
(snarf-bindings (cdr x))))))
((and symbol (not keyword)) x)
(t (let ((name (gensym)))
(push (list name x) renamed-bindings)
name)))))
(let ((real-body (remove-declares body)))
`(destructuring-bind ,(snarf-bindings macro-lambda-list) ,value-form
,@(nreverse declares)
,@(loop for (k x) in (nreverse renamed-bindings) collect
`(assert (equal ,k ,x) nil
"Failed to match ~S against ~S." ,k ,x))
,@real-body)))))

#+elisp
(put 'destructuring-match 'common-lisp-indent-function '((&whole 6 &rest 1) 4 &body))
```

Re: destructuring-match - the name of the game

<te36fl$329vk$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17170&group=comp.lang.lisp#17170

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: destructuring-match - the name of the game
Date: Tue, 23 Aug 2022 18:32:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <te36fl$329vk$1@dont-email.me>
References: <m3a67v553n.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 23 Aug 2022 18:32:22 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6aa50267a486b2eda23f47801954e414";
logging-data="3221492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18T//IBMxzfhpHoiPwcwvTQIcs7lolzo14="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:dgb3XBX27usZhmD0rUE600V142k=
sha1:kh4KPz1Nz3k6U5FuhDzyWGNxBeg=
 by: Zyni Moë - Tue, 23 Aug 2022 18:32 UTC

Madhu <enometh@net.meer> wrote:
> It looks like tim bradshaw has published a macro called
> destructring-match which sounds like destructuring bind but looks
> more like elisp's pcase with additional multiple match clauses and
> additional (:when ..) syntax. I would disagree with the name,
> because it doesn't seem to be analogous to lisp's destructuring

Each lambda list in

(destructuring-match <form>
(<lambda-list> ...)
(<lambda-list> ...)
...
(otherwise ...))

is full destructuring-bind lambda list (so, macro lambda list without
environment etc). In that sense yes, it is exactly common lisp's
destructuring.

In fact is easy:

(defmacro destructuring-bind (ll form &body forms)
`(destructuring-match ,form
(,ll ,@forms)
(otherwise (error "fleașcă"))))

Think you may be confuse dsm with spam which is in its implementation (I do
not know pcase you mention). In fact destructuring-bind os more safely
implement using both dsm for the work and spam for toxin prevention

(defmacro destructuring-bind (ll form &body forms)
(matching forms
((head-matches (repeating-list-of (some-of (is ':when)
(is ':unless))
(any)))
(error "futu-i"))
(otherwise
`(destructuring-match ,form
(,ll ,@forms)
(otherwise (error "fleașcă"))))))

Even this is not quite right: really you need to parse forms a little, so:

(defmacro destructuring-bind (ll form &body decls/forms)
(multiple-value-bind (decls forms) (parse-simple-body decls/forms)
`(destructuring-match ,form
(,ll
,@decls
(progn ,@forms)))
(otherwise (error "fleașcă"))))

This still may be wrong but is close.

--
the small snake

Re: destructuring-match - the name of the game

<m35yii5pqn.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17171&group=comp.lang.lisp#17171

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: enometh@net.meer (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: destructuring-match - the name of the game
Date: Wed, 24 Aug 2022 08:09:44 +0530
Organization: Motzarella
Lines: 46
Message-ID: <m35yii5pqn.fsf@leonis4.robolove.meer.net>
References: <m3a67v553n.fsf@leonis4.robolove.meer.net>
<te36fl$329vk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="4ec28be9852f5477374f8dd9e5d481d5";
logging-data="3396195"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/P/UozD5/Pr7cDQlMe612rrU/lNrlzank="
Cancel-Lock: sha1:yYyZ47rvvC48ILn6jlZTki/dmt4=
sha1:rzP9Frvuy/mJ/Qt2UDPhH8qqR4U=
 by: Madhu - Wed, 24 Aug 2022 02:39 UTC

* Zyni Moë <te36fl$329vk$1@dont-email.me> :
Wrote on Tue, 23 Aug 2022 18:32:22 -0000 (UTC):

> Madhu <enometh@net.meer> wrote:
>> It looks like tim bradshaw has published a macro called
>> destructring-match which sounds like destructuring bind but looks
>> more like elisp's pcase with additional multiple match clauses and
>> additional (:when ..) syntax. I would disagree with the name,
>> because it doesn't seem to be analogous to lisp's destructuring
>
> Each lambda list in
>
> (destructuring-match <form>
> (<lambda-list> ...)
> (<lambda-list> ...)
> ...
> (otherwise ...))
>
> is full destructuring-bind lambda list (so, macro lambda list without
> environment etc). In that sense yes, it is exactly common lisp's
> destructuring.

No the top level surface syntax is analogous to CL's CASE (or COND).

The name of the macro should reflect that it is a bunch of case clauses
or at least call it match-destructuring.

I think each clause which you have denoted as (<lambda-list> ...) also
has additional syntax (a cl-loopish :when in the ... forms, and loop is
apparently abhorred by the author)

Only the clauses involve destructuring.

> In fact is easy:
>
> (defmacro destructuring-bind (ll form &body forms)
> `(destructuring-match ,form
> (,ll ,@forms)
> (otherwise (error "fleașcă"))))
>
> Think you may be confuse dsm with spam which is in its implementation (I do
> not know pcase you mention). In fact destructuring-bind os more safely
> implement using both dsm for the work and spam for toxin prevention

Thanks, I'll get around to looking at it at some point.

Re: destructuring-match - the name of the game

<te4n52$397of$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17172&group=comp.lang.lisp#17172

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: destructuring-match - the name of the game
Date: Wed, 24 Aug 2022 08:22:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <te4n52$397of$1@dont-email.me>
References: <m3a67v553n.fsf@leonis4.robolove.meer.net>
<te36fl$329vk$1@dont-email.me>
<m35yii5pqn.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 24 Aug 2022 08:22:58 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b921225f6a0ab747d1a4dcd8892fbbd8";
logging-data="3448591"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rMp6WqjX4KdCQaHd17stuzSd4AfXnSjQ="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:lGhlXr6C6ia3478zvPpVl7dmWLg=
sha1:2S5+A+MuRD0CGQutVR4P+hTEmz4=
 by: Zyni Moë - Wed, 24 Aug 2022 08:22 UTC

Madhu <enometh@net.meer> wrote:

> The name of the macro should reflect that it is a bunch of case clauses
> or at least call it match-destructuring.

Oh I had not realised your problem was so petty and stupid, would not have
wasted time replying if I knew that. But, well, you are old lisp person I
think: only thing lisp people really do well is petty and stupid. It's a
'*-match' macro, it should work the way match macros do, which is like
case.

Fairly sure his problem with loop is that it is a nightmare to parse, I
will ask next time I see him.

--
the small snake

Re: destructuring-match - the name of the game

<m3zgfu3sp2.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17173&group=comp.lang.lisp#17173

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: enometh@net.meer (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: destructuring-match - the name of the game
Date: Wed, 24 Aug 2022 14:48:49 +0530
Organization: Motzarella
Lines: 29
Message-ID: <m3zgfu3sp2.fsf@leonis4.robolove.meer.net>
References: <m3a67v553n.fsf@leonis4.robolove.meer.net>
<te36fl$329vk$1@dont-email.me>
<m35yii5pqn.fsf@leonis4.robolove.meer.net>
<te4n52$397of$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="f5e4878bf63684c29aa970eb39bd9c99";
logging-data="3456645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wLTBVPVt7D6/5BfoJMDrkpxeHvxY2fr0="
Cancel-Lock: sha1:oP9iVFlhj0aqNa3Ax9/47pbG7v4=
sha1:yYqvWM3cq4SLRwNor7DeCx9t0Tc=
 by: Madhu - Wed, 24 Aug 2022 09:18 UTC

* Zyni Moë <te4n52$397of$1@dont-email.me> :
Wrote on Wed, 24 Aug 2022 08:22:58 -0000 (UTC):
> Oh I had not realised your problem was so petty and stupid, would not
> have wasted time replying if I knew that.

Your initial response was easily identifiable as a knee-jerk defence of
a (probably unworthy) hero's design decisions, and your follow up
confirms that

> But, well, you are old lisp person I think: only thing lisp people
> really do well is petty and stupid. It's a '*-match' macro, it should
> work the way match macros do, which is like case.

There is a unifying principle in common lisp design, not statable ,
which can nevertheles be grasped by practioners - similar to how
biblical texts can identified to be canonical because they "fit". TFEBs
macro does not "fit" either in the naming or in the syntax. I suspect
Much of tfeb's canards against trivia would also apply to hiw work.

> Fairly sure his problem with loop is that it is a nightmare to parse,
> I will ask next time I see him.

Don't bother - I'm sure there is some nuanced dissonance behind that
that you are sure miss or will be unable to grasp even if you saw it.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor