unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 64584@debbugs.gnu.org
Subject: bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions
Date: Tue, 12 Sep 2023 20:20:56 +0530	[thread overview]
Message-ID: <87ttrzjvhr.fsf@gmail.com> (raw)
In-Reply-To: <jwvh6nz4ka8.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 12 Sep 2023 09:08:09 -0400")

[செவ்வாய் செப்டம்பர் 12, 2023] Stefan Monnier wrote:

>> Yes, but here it basically does nothing unfortunately.  I am not sure if
>>
>>     'str
>>
>> should have the side effect of setting that variable.
>
> The above skeleton expression means "eval the variable `str` and throw
> away the result".  The only effect it can have is to signal an error if
> the variable `str` is not bound.

Ah yes, of course.  I am still thinking in vague terms of macroexpansion
which is leading to all the misunderstandings.

>>     (defmacro vz/snippet-when (form &rest body)
>>       "Evaluate BODY if FORM returns non-nil or non-empty string."
>>       (declare (indent 1) (debug (form body)))
>>       `(let ((str ,form))
>>          (if (and str (equal str ""))
>>              ""
>>            ,@body)))
>
> FWIW, this style of macro is usually called "anaphoric macro" and the
> convention is to use the identifier `it` rather than `str` in them.
> It would help avoid a confusion between skeleton's `str` and your
> macro's variable.

Oh yes, I called `it' first but changed it `str' "in anger".  So far, I
haven't been in the need of using both vz/snippet-when's `str' and
skeleton's `str' so I will let the sleeping dogs lie.

> [ And, yes, arguably, `define-skeleton` could be considered as an
>   anaphoric macro as well which should use `it` instead of `str`,
>   bringing back the confusion :-)  ]

I guess it wasn't chosen because there are other variables too (like
help, v1, v2, etc.).

I cannot think of any improvements to the documentation since the spawn
of this bug report is rooted in a lack of understanding of how skeleton
works.  There is nothing to fix here except my understanding so I'm
closing the bug report with this.  Thank you again for your time,
Stefan.





      reply	other threads:[~2023-09-12 14:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 17:05 bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions Visuwesh
2023-09-11 13:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 15:20   ` Visuwesh
2023-09-11 22:12     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12  2:36       ` Visuwesh
2023-09-12  3:06         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 12:24           ` Visuwesh
2023-09-12 13:08             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-12 14:50               ` Visuwesh [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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ttrzjvhr.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=64584@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).