unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Lars Ingebrigtsen <larsi@gnus.org>,
	emacs-devel@gnu.org
Subject: Re: Always-true predicate?
Date: Fri, 19 Feb 2021 11:27:52 +0000	[thread overview]
Message-ID: <CAOqdjBc7w6ErPYVn0Wk9FUMNCs1MUDPCK78WoWjV+E0m0NZnvA@mail.gmail.com> (raw)
In-Reply-To: <jwv35xu9u7u.fsf-monnier+emacs@gnu.org>

On Wed, Feb 17, 2021 at 11:01 PM Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> > Seriously: I remember one case when I tried to find CONSTANTLY or
> > similar but failed. I wrote some LAMBDA form. No big deal.
>
> Maybe we should let `lambda` take arguments like Scheme does, i.e.
> (lambda (a b . c) FOO) instead of (lambda (a b &rest c) FOO), and in that
> case we could simple use "lambda _" as a shorthand for "constantly".

That would break things like pcase-lambda, though: we would no longer
be able to generalize lambda meaningfully.

TL;DR - let's make (lambda (&rest) t) valid for the universal
predicate and leave it at that.

Anyway, my problem with variadic functions isn't defining them, it's
calling them. I think I should be able to say

(f a b c &rest d)

rather than

(apply #'f a b c d)

which would make usage mimic declaration. Kind of like JavaScript's
... operator (and in fact that would be a better name for it than
&rest, IMHO, though of course it should be a symbol rather than extra
syntax). (For extra fun, consider

(f &rest a &rest b) = (apply #'f (append a b))

and

(f &rest keywords values) = (apply #'f (zip keywords values))

(I don't like apply, even when it's not (apply nil), mostly because

(apply #'f 'a 'b nil)

isn't necessarily equivalent to

(f 'a 'b) [1])

As for the universal predicate, I'd like to be able to write (lambda
(&rest) t), which would save two characters. (lambda (...) t) would
save another one :-) )

And if we can require optional arguments, why can't we provide them
optionally? For example, let's say in Emacs 33 we want to expand
copy-marker with a new argument to more clearly describe how the
marker repositions itself relative to other markers (or implicit)
markers at the same character position. But (copy-marker marker nil
&optional 'something) would work in Emacs 32 (which would include the
optionally-provided argument extension), and be equivalent to
(copy-marker marker nil) there.

Pip

[1] - if f is a macro, for example. The byte compiler has a fun bug if
you feed it this input:

(defun eval-then-throw (a b)
  (apply #'or a (eval b) nil))

(eval-then-throw t '(message "printme"))
(byte-compile 'eval-then-throw)
(eval-then-throw t '(message "printme"))



  reply	other threads:[~2021-02-19 11:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 12:01 Always-true predicate? Lars Ingebrigtsen
2021-02-17 12:31 ` Andrea Corallo via Emacs development discussions.
2021-02-17 12:40   ` Lars Ingebrigtsen
2021-02-17 16:59     ` Barry Fishman
2021-02-19 15:24   ` Stefan Kangas
2021-02-17 13:16 ` Basil L. Contovounesios
2021-02-17 18:56   ` Pip Cet
2021-02-17 19:19     ` Lars Ingebrigtsen
2021-02-17 19:31       ` Pip Cet
2021-02-17 19:37         ` Lars Ingebrigtsen
2021-02-17 20:18           ` Teemu Likonen
2021-02-17 22:25             ` [External] : " Drew Adams
2021-02-17 23:04               ` Basil L. Contovounesios
2021-02-17 23:13                 ` Drew Adams
2021-02-17 23:01             ` Stefan Monnier
2021-02-19 11:27               ` Pip Cet [this message]
2021-02-19 15:07                 ` Stefan Monnier
2021-02-19 19:04                   ` Pip Cet
2021-02-19 20:11                     ` Stefan Monnier
2021-02-20  9:40                       ` Pip Cet
2021-02-20 13:58                         ` Stefan Monnier
2021-02-19  5:39 ` Richard Stallman
2021-02-19  8:52   ` Robert Pluim
2021-02-19  9:10     ` Eli Zaretskii
2021-02-19 12:12       ` Eli Zaretskii
2021-02-19 12:52       ` Stefan Kangas
2021-02-19 13:00         ` Lars Ingebrigtsen
2021-02-19 13:34         ` Eli Zaretskii
2021-02-19 13:40           ` Lars Ingebrigtsen
2021-02-19 13:53             ` Eli Zaretskii
2021-02-19 14:05               ` Lars Ingebrigtsen
2021-02-19 18:04                 ` [External] : " Drew Adams
2021-02-19 14:42             ` Stefan Monnier
2021-02-20 12:47               ` Lars Ingebrigtsen
2021-02-20 12:49                 ` Lars Ingebrigtsen
2021-02-20 14:03                   ` Stefan Monnier
2021-02-20 14:20                     ` Lars Ingebrigtsen
2021-02-20 14:55                       ` Stefan Monnier
2021-02-20 15:05                         ` Lars Ingebrigtsen
2021-02-20 15:21                           ` Stefan Monnier
2021-02-21 12:50                             ` Robert Pluim
2021-02-21 13:04                             ` Lars Ingebrigtsen
2021-02-19 15:09           ` Stefan Kangas
2021-02-19 15:22             ` Eli Zaretskii
2021-02-19 18:17               ` [External] : " Drew Adams
2021-02-19 18:41                 ` Eli Zaretskii
2021-02-22  5:02       ` chad
2021-02-22 15:20         ` Eli Zaretskii
2021-02-22 23:07           ` chad
2021-02-21  6:12     ` Richard Stallman
2021-02-21 15:12       ` Eli Zaretskii

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=CAOqdjBc7w6ErPYVn0Wk9FUMNCs1MUDPCK78WoWjV+E0m0NZnvA@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=contovob@tcd.ie \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.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).