all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Getting rid of cl--block-wrapper and cl--block-throw
@ 2024-07-24  2:14 Thuna
  2024-07-24 12:46 ` Andrea Corallo
  0 siblings, 1 reply; 3+ messages in thread
From: Thuna @ 2024-07-24  2:14 UTC (permalink / raw)
  To: emacs-devel

Is there a particular benefit to `cl-block' and `cl-return{,from}'
expanding into forms which then further expand via their compiler-macros
when what the compile-macro does can (and should) be done in the macros
themselves?

I am currently doing some work in cl-*.el files (I'll post about that
soon) and part of my changes involve these macros, so I was wondering if
I was free to ditch the compiler macros or if there was a reason why
they had to be kept around.

Part of my gripe with these compiler macros is that, AFAICT, they are
not truly optimizations but the actual expected behavior instead; they
are what ensures that the block is only established if a lexical return
exits.[1]

Also, since I'm here I should also check - are there any significant
backwards compatibility problems associated with these macros?  That is,
can I assume that no one will be left with stale `cl--block-wrapper' and
`cl--block-throw's in packages and that no code exists which depends on
cl-block's actual catch tags having predictable names?  The former is
unlikely to be found in the wild, but the latter is quite likely[2], so
the actual question is about Emacs' policy in this situation.

[1] And, while I do not know how to go about demonstrating it, if the
compiler macros were to somehow not expand then exits from outside the
lexical scope would still work, which goes against the documentation of
cl-block.

[2] A quick git grep on elpa for `--cl-block-' and
`cl--block-(wrapper|throw)' seems to only bring up `relint.el' (which
compares the head against the symbol `cl--block-wrapper' in a cond),
which won't actually break as a result of removing the wrappers AFAICT
but will maybe stop working with cl-blocks.

[PS] And *and*, just though of it while writing this, there might be a
bug if a `cl-block' is not optimized away, possibly due to the existence
of a legitimate `cl-return' and a function called returns from the
block's name ... and indeed:

  (defun foo () (cl-return "ruh roh"))
  (cl-block nil (foo) (cl-return t)) ; => "ruh roh"

There is likely a bug report for this though so I'll leave this here as
a side-note.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-24 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24  2:14 Getting rid of cl--block-wrapper and cl--block-throw Thuna
2024-07-24 12:46 ` Andrea Corallo
2024-07-24 16:14   ` Thuna

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.