GNU bug report logs - #64584
29.0.91; skeleton: cannot pass `str' as argument to some functions

Previous Next

Package: emacs;

Reported by: Visuwesh <visuweshm <at> gmail.com>

Date: Wed, 12 Jul 2023 17:07:01 UTC

Severity: normal

Found in version 29.0.91

Done: Visuwesh <visuweshm <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Visuwesh <visuweshm <at> gmail.com>
Cc: 64584 <at> debbugs.gnu.org
Subject: bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions
Date: Tue, 12 Sep 2023 09:08:09 -0400
> 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.

>     (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.

[ 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 :-)  ]


        Stefan





This bug report was last modified 1 year and 344 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.