all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Joost Kremers <joostkremers@fastmail.fm>
To: Drew Adams <drew.adams@oracle.com>
Cc: "Alfred M. Szmidt" <ams@gnu.org>,
	 arthur miller <arthur.miller@live.com>,
	 "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [External] : Re: Better documentation for non-binding clauses of if-let and friends
Date: Tue, 12 Nov 2024 09:07:54 +0100	[thread overview]
Message-ID: <86a5e4vpr9.fsf@fastmail.fm> (raw)
In-Reply-To: <DS7PR10MB5232F79F2E95661F0C9794EBF3592@DS7PR10MB5232.namprd10.prod.outlook.com> (Drew Adams's message of "Tue, 12 Nov 2024 00:26:07 +0000")

On Tue, Nov 12 2024, Drew Adams wrote:
> This is your if-let*, with space separation of
> bindings from conditions:
>
>> (if-let* ((           (parsebib--char "@"))
>>           (           (parsebib--keyword '("string")))
>>           (open       (parsebib--char "{("))
>              ^^^^1
>>           (definition (parsebib--assignment))
>              ^^^^^^^^^^1
>>           (           (parsebib--char
>                           (alist-get
>                             open '((?\{ . "}") (?\( . ")"))))))
>                             ^^^^2
>>     definition
>       ^^^^^^^^^^2
>>   (signal 'parsebib-error
>>           (list (format "Malformed @String definition at position %d,%d"
>>                         (line-number-at-pos) (current-column)))))
>
> Implied and-ing is all the if-let* gets you, at
> least in this example.  At the cost of a loss of
> obvious distinction between binding and use
> occurrences.

I don't see the loss. The `if-let*` version has two occurrences of `open`
and `definition`: the first is the binding, the second is the use. Without
`if-let*`, I need to repeat both once more to test if they're non-nil.
Those occurrences and the `and`s are there to make the code do what I want,
but they don't help express the idea behind the code, so to my mind they're
boilerplate.

> I guess your parser grammar rule (not shown) just
> has the (parsebib-*...) conditions as literal
> match patterns, and it has `open' and `definition'
> as nonterminals.

`post` is also a literal, I'm just capturing it so I can make sure I get
the corresponding closing delimiter. Otherwise you could close a curly
brace { with a parenthesis ) or vice versa. (Yes, this is cheating, I
know...) `definition` is a non-terminal (and should probably be called
`assignment`).

> In any case, you said you didn't know what an
> "equivalent without `if-let*` would look like".
> So I mentioned that `macroexpand' has the answer.

True, it didn't occur to me to look at it.

> And the answer isn't very complex.  In this case,
> at least, it just makes the and-ing of binding
> dependencies explicit/clear.

Which I feel is unnecessary and even a hindrance.

-- 
Joost Kremers
Life has its moments



      reply	other threads:[~2024-11-12  8:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11  9:28 Better documentation for non-binding clauses of if-let and friends arthur miller
2024-11-11  9:58 ` Alfred M. Szmidt
2024-11-11 10:23   ` Sv: " arthur miller
2024-11-11 10:26   ` Joost Kremers
2024-11-11 10:53     ` Sv: " arthur miller
2024-11-11 11:18       ` Joost Kremers
2024-11-11 21:21     ` [External] : " Drew Adams
2024-11-11 22:51       ` Joost Kremers
2024-11-12  0:26         ` Drew Adams
2024-11-12  8:07           ` Joost Kremers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86a5e4vpr9.fsf@fastmail.fm \
    --to=joostkremers@fastmail.fm \
    --cc=ams@gnu.org \
    --cc=arthur.miller@live.com \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.