[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Always-true predicate?
From: |
Lars Ingebrigtsen |
Subject: |
Always-true predicate? |
Date: |
Wed, 17 Feb 2021 13:01:45 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Currently, Emacs has:
----
Sometimes, when you call a functional, it is useful to supply a no-op
function as the argument. Here are two different kinds of no-op
function:
-- Function: identity argument
This function returns ARGUMENT and has no side effects.
-- Function: ignore &rest arguments
This function ignores any ARGUMENTS and returns ‘nil’.
----
`identity' is kinda-sorta used as the opposite of `ignore' many places
where you're feeding predicates to functions, but takes only one
parameter and, of course, returns nil if you give it nil.
Would it make sense to add a function that's exactly the opposite of
`ignore' (for symmetry and convenience)? If so, what would it be
called?
I've googled to see what other languages do. Rust and NPM has "always",
and many more Java-inspired frameworks have "truePredicate", but this
isn't trivial to google for...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Always-true predicate?,
Lars Ingebrigtsen <=