unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: akater <nuclearspace@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Improve detection of local function calls in methods
Date: Fri, 10 Sep 2021 11:49:59 -0400	[thread overview]
Message-ID: <jwvr1dwmoov.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ee9xq74a.fsf@gmail.com> (akater's message of "Fri, 10 Sep 2021 06:25:57 +0000")

> - (func exp) is non-standard and ad-hoc.

(FUNC EXP) is indeed non-standard.  But I completely disagree with
`ad-hoc`: IMO this form is the fundamental form of `flet` (it
corresponds directly to `let`, just in the function namespace) and
the form (FUNC ARGS &rest BODY) should be viewed as a simple syntactic
sugar for the common case of (FUNC (lambda ARGS &rest BODY)).

>   Do you happen to remember, maybe it was invented solely for
>   ~cl--generic-lambda~?

It was added to Emacs's `master` for the purpose of
`cl--generic-lambda`, yes.  It was invented long before, OTOH ;-)
[ I still can't explain how I forgot to add it when we moved from
  `flet` to `cl-flet` in Emacs-24.3.  ]

> - (func exp) definition form is described incorrectly in the docstring:
>   it should be (FUNCTION-NAME SYMBOL) and so on;

Not sure what you mean here.  Do you mean `func` should be
`function-name` since this should be a symbol and not a function?
[ I would agree with that, tho `function-name` would be longish so
  I'd rather go maybe with just `name`.  ]
Or do you mean that `exp` should be `symbol`?
If so, I disagree because this allows an arbitrary expression that's
evaluated before its resulting value is bound to the specified function
symbol.

>   this also affects `cl-macrolet` docstring which claims it's “like
>   `cl-flet`” but in fact it's not as it doesn't support this definition
>   form

Indeed, this was not updated when `cl-flet` was extended.
Not sure what's best to do here:
- we could extend `cl-macrolet` to also accept (NAME EXP), but this is
  much less useful for macros since EXP is evaluated in the
  macroexpansion context.
- tweak the docstring to clarify the "like"ness.

> - ~cl-flet~ with invalid function names should error but it doesn't

You mean if the "function name" is not a symbol?
Indeed, it would be better to signal an error in that case.

> This involves a “macro” version of expand-flet; we'll see whether it's
> worth keeping alongside the corresponding function.

Your sample code looks OK, tho I don't think having a macro for it is
worth the trouble.


        Stefan




      reply	other threads:[~2021-09-10 15:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 21:41 [PATCH] Improve detection of local function calls in methods akater
2021-08-27 22:59 ` Stefan Monnier
2021-08-29 11:25   ` akater
2021-09-02 18:34     ` Stefan Monnier
2021-09-10  6:25       ` akater
2021-09-10 15:49         ` Stefan Monnier [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=jwvr1dwmoov.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=nuclearspace@gmail.com \
    /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).