* bug#25129: 26.0.50; seq-some function
@ 2016-12-07 8:09 Pierre Lorenzon
2016-12-07 8:48 ` Nicolas Petton
0 siblings, 1 reply; 9+ messages in thread
From: Pierre Lorenzon @ 2016-12-07 8:09 UTC (permalink / raw)
To: 25129
Is documentation in following seq-somme function not ambiguous
? One might believe taht it returns the element and not the
test result as it does. Moreover I suspect even if I did not
verify that it was not so in a previous implementation since I
had no error in my code before using seq-some.
I well understand now that I must use seq-find instead of
seq-some but I think that I will not be the only one being
confused by these functions specifications !
In fact there is a very subtle difference between two
documentation : value not equal element .... But what means
value ? Is it obvious taht it means test result ?
Regards
Pierre
>>> -- Code
(cl-defgeneric seq-some (pred sequence)
"Return the first value for which if (PRED element) is non-nil for in SEQUENCE."
(catch 'seq--break
(seq-doseq (elt sequence)
(let ((result (funcall pred elt)))
(when result
(throw 'seq--break result))))
nil))
(cl-defgeneric seq-find (pred sequence &optional default)
"Return the first element for which (PRED element) is non-nil in SEQUENCE.
If no element is found, return DEFAULT.
Note that `seq-find' has an ambiguity if the found element is
identical to DEFAULT, as it cannot be known if an element was
found or not."
(catch 'seq--break
(seq-doseq (elt sequence)
(when (funcall pred elt)
(throw 'seq--break elt)))
default))
>>> -- End Code
In GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu)
of 2016-11-15 built on jabberwocky
Repository revision: db43613307bb05d0f43d2d5649b5bb2f29876cee
Recent messages:
Mark set
Making completion list...
Type "q" in help window to restore its previous buffer, C-M-v to scroll help.
line-move-visual: End of buffer
mouse-2, RET: find function's definition
uncompressing seq.el.gz...done
Note: file is write protected
Unable to find location in file
Mark saved where search started
Making completion list...
Configured using:
'configure --prefix=/usr --libdir=/usr/lib64 'CC=gcc -m64'
PKG_CONFIG_PATH=/usr/lib64/pkgconfig'
Configured features:
JPEG SOUND NOTIFY GNUTLS LIBXML2 ZLIB
Important settings:
value of $LANG: C
locale-coding-system: nil
Major mode: Emacs-Lisp
Minor modes in effect:
gpm-mouse-mode: t
global-ede-mode: t
ede-minor-mode: t
desktop-save-mode: t
global-speechd-speak-mode: t
speechd-speak-mode: t
global-speechd-speak-map-mode: t
speechd-speak-map-mode: t
tooltip-mode: t
electric-indent-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
/usr/local/share/emacs/site-lisp/customization/site-start hides /usr/share/emacs/site-lisp/site-start
Features:
(shadow emacsbug sendmail thingatpt eieio-opt
j++-packages-sound-alsa-enumerated
j++-packages-sound-alsa-iec958 j++-packages-sound-alsa-boolean
j++-basic-widgets-synchronized-switch j++-basic-parsers-slot
j++-packages-sound-alsa-two-integer
j++-basic-widgets-synchronized-two-incdec
j++-packages-sound-alsa-integer
j++-basic-widgets-synchronized-incdec
j++-basic-widgets-bar-title
j++-basic-widgets-synchronized-object
j++-packages-sound-alsa-item j++-packages-sound-alsa-amixer
j++-interfaces-pointed j++-packages-sound-alsa-cclient
j++-packages-sound-alsa-client j++-basic-parsers-parser
j++-basic-parsers-utils utils/regexp utils/string
j++-basic-synchronized j++-basic-processes-synchronous
j++-basic-processes-command help-fns radix-tree debug vc-cvs
vc-rcs misearch multi-isearch pp qp mew-varsx mew-unix
inversion make-mode ede/srecode compile comint ansi-color
log-edit easy-mmode message rfc822 mml mml-sec epa derived epg
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader ring pcvs-util add-log
j++-packages-subsystems-descriptors-creator dired-aux
j++-packages-scmel-results j++-packages-scmel-output
speechd-el-extension t-mouse term/linux vc-dir ewoc ede/dired
semantic/lex-spp pln-w3m mew-w3m w3m regexp-opt doc-view dired
dired-loaddefs image-mode timezone w3m-hist w3m-fb bookmark-w3m
w3m-ems w3m-ccl ccl w3m-favicon w3m-image w3m-proc w3m-util
mew-auth mew-config mew-imap2 mew-imap mew-nntp2 mew-nntp
mew-pop mew-smtp mew-ssl mew-ssh mew-net mew-highlight mew-sort
mew-fib mew-ext mew-refile mew-demo mew-attach mew-draft
mew-message mew-thread mew-virtual mew-summary4 mew-summary3
mew-summary2 mew-summary mew-search mew-pick mew-passwd
mew-scan mew-syntax mew-bq mew-smime mew-pgp mew-header
mew-exec mew-mark mew-mime mew-edit mew-decode mew-encode
mew-cache mew-minibuf mew-complete mew-addrbook mew-local
mew-vars3 mew-vars2 mew-vars mew-env mew-mule3 mew-mule
mew-gemacs mew-key mew-func mew-blvs mew-const mew pln-mew
pln-eww url-file url-dired eww mm-url gnus nnheader gnus-util
rmail tool-bar rmail-loaddefs rfc2047 rfc2045 ietf-drums
mail-utils mm-util mail-prsvr url-queue url url-proxy
url-privacy url-history url-cookie url-domsuf mailcap shr svg
xml dom browse-url format-spec url-expand url-util url-methods
url-parse url-vars Tss-TeX-remap tex-style-system tex-site
auto-loads j++-packages-databases-actions
j++-basic-widgets-bar-object
j++-packages-subsystems-descriptors-descriptor
j++-packages-subsystems-descriptors-class
j++-packages-databases-items-item j++-basic-mastered
j++-basic-widgets-open-close-title j++-basic-widgets-title
j++-basic-widgets-open-close-object
j++-packages-subsystems-subsystems
j++-packages-databases-database j++-packages-databases-mutable
j++-interfaces-loadable-basic-logger
j++-interfaces-basic-logger
j++-interfaces-loadable-basic-lists-pointed
j++-interfaces-basic-lists-pointed
j++-basic-widgets-lists-pointed j++-basic-lists-pointed
j++-basic-creator j++-interfaces-loadable-basic-lists-list
j++-interfaces-basic-lists-list j++-basic-widgets-lists-list
j++-basic-lists-list j++-basic-mapable j++-basic-sortable
j++-project j++-packages-project-project j++-basic-files-file
edext-project-latex edext-project-project edext-utils-vc vc-svn
vc vc-dispatcher edext-target-exercise edext-target-history
edext-target-student edext-target-latex edext edext-automake
edext-srecode semantic/edit srecode/srt-mode semantic/analyze
semantic/sort semantic/scope semantic/analyze/fcn semantic/db
semantic/format srecode/template srecode/srt-wy semantic/wisent
semantic/wisent/wisent semantic/ctxt edext-compat pln-ede
srecode/insert srecode/filters srecode/args srecode/find
srecode/map srecode/ctxt semantic/tag-ls semantic/find
srecode/compile srecode/dictionary srecode/table srecode
semantic/util-modes semantic/util semantic semantic/tag
semantic/lex semantic/fw mode-local find-func ede/proj-elisp
ede/pconf ede/proj-misc ede/proj-shared ede/proj-prog ede/pmake
ede/proj-obj ede/proj ede/make ede/proj-comp ede/autoconf-edit
autoconf autoconf-mode pln-auctex pln-customization
ede/speedbar ede/files ede ede/detect ede/base ede/auto
ede/source eieio-speedbar speedbar sb-image ezimage image
dframe cedet desktop frameset cus-start cus-load time-date
j++-packages-scmel-efm-parameters
j++-packages-scmel-efm-connection network-stream puny nsm
subr-x auth-source password-cache starttls tls gnutls
j++-packages-scmel-efm-driver j++-packages-scmel-efm-efm
j++-packages-scmel-monitor j++-packages-scmel-scmel
j++-basic-logger j++-basic-processes-network-filtered
j++-basic-processes-filtered j++-basic-processes-put-and-get
j++-basic-processes-network-stream j++-basic-processes-process
j++-packages-subsystems-subsystem
j++-interfaces-loadable-loadable j++-interfaces-interface
j++-basic-widgets-object warnings j++-basic-files-loadable
j++-basic-state j++-basic-files-serializable
j++-basic-files-stringifiable j++-basic-files-load eieio-base
eieio-custom wid-edit speechd-speak advice speechd-brltty
speechd-braille braille mmanager brltty speechd-ssip speechd
speechd-out eieio-compat cl-seq speechd-common jka-compr j++
j++-compat j++-precompat eieio eieio-core cl-macs
eieio-loaddefs seq byte-opt bytecomp byte-compile cl-extra
help-mode easymenu cconv cl gv cl-loaddefs pcase cl-lib
mule-util disp-table tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese
eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable
backquote inotify multi-tty make-network-process emacs)
Memory information:
((conses 16 402793 68817)
(symbols 48 40865 109)
(miscs 40 1386 237)
(strings 32 90674 7379)
(string-bytes 1 2616687)
(vectors 16 45189)
(vector-slots 8 963465 20687)
(floats 8 1962 250)
(intervals 56 8907 541)
(buffers 976 76)
(heap 1024 45549 1348))
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 8:09 bug#25129: 26.0.50; seq-some function Pierre Lorenzon
@ 2016-12-07 8:48 ` Nicolas Petton
2016-12-07 10:19 ` Tino Calancha
2016-12-07 16:28 ` Pierre Lorenzon
0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Petton @ 2016-12-07 8:48 UTC (permalink / raw)
To: Pierre Lorenzon, 25129
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
Pierre Lorenzon <devel@pollock-nageoire.net> writes:
Hi Pierre,
> I well understand now that I must use seq-find instead of
> seq-some but I think that I will not be the only one being
> confused by these functions specifications !
There is a mistake (extra if) in the documentation, I will fix that.
Other than that, is the following less confusing?
Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
If so, return the value returned by PRED.
Cheers,
Nico
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 8:48 ` Nicolas Petton
@ 2016-12-07 10:19 ` Tino Calancha
2016-12-07 10:24 ` Nicolas Petton
2016-12-07 16:28 ` Pierre Lorenzon
1 sibling, 1 reply; 9+ messages in thread
From: Tino Calancha @ 2016-12-07 10:19 UTC (permalink / raw)
To: Nicolas Petton; +Cc: 25129, tino.calancha
Nicolas Petton <nicolas@petton.fr> writes:
> Pierre Lorenzon <devel@pollock-nageoire.net> writes:
>
> Hi Pierre,
>
>> I well understand now that I must use seq-find instead of
>> seq-some but I think that I will not be the only one being
>> confused by these functions specifications !
>
> There is a mistake (extra if) in the documentation, I will fix that.
>
> Other than that, is the following less confusing?
>
> Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
> If so, return the value returned by PRED.
The previous doc string contains more information: it explicitely says
that it returns the _first_ non-nil (PRED element).
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 10:19 ` Tino Calancha
@ 2016-12-07 10:24 ` Nicolas Petton
2016-12-07 10:31 ` Tino Calancha
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Petton @ 2016-12-07 10:24 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25129, tino.calancha
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
Tino Calancha <tino.calancha@gmail.com> writes:
> Nicolas Petton <nicolas@petton.fr> writes:
>
>> Pierre Lorenzon <devel@pollock-nageoire.net> writes:
>>
>> Hi Pierre,
>>
>>> I well understand now that I must use seq-find instead of
>>> seq-some but I think that I will not be the only one being
>>> confused by these functions specifications !
>>
>> There is a mistake (extra if) in the documentation, I will fix that.
>>
>> Other than that, is the following less confusing?
>>
>> Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
>> If so, return the value returned by PRED.
> The previous doc string contains more information: it explicitely says
> that it returns the _first_ non-nil (PRED element).
Indeed, what about:
Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
If so, return the first non-nil value returned by PRED.
Cheers,
Nico
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 10:24 ` Nicolas Petton
@ 2016-12-07 10:31 ` Tino Calancha
2016-12-07 12:31 ` Nicolas Petton
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Tino Calancha @ 2016-12-07 10:31 UTC (permalink / raw)
To: Nicolas Petton; +Cc: 25129, Tino Calancha
On Wed, 7 Dec 2016, Nicolas Petton wrote:
> Tino Calancha <tino.calancha@gmail.com> writes:
>
>> Nicolas Petton <nicolas@petton.fr> writes:
>>
>>> Pierre Lorenzon <devel@pollock-nageoire.net> writes:
>>>
>>> Hi Pierre,
>>>
>>>> I well understand now that I must use seq-find instead of
>>>> seq-some but I think that I will not be the only one being
>>>> confused by these functions specifications !
>>>
>>> There is a mistake (extra if) in the documentation, I will fix that.
>>>
>>> Other than that, is the following less confusing?
>>>
>>> Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
>>> If so, return the value returned by PRED.
>
>> The previous doc string contains more information: it explicitely says
>> that it returns the _first_ non-nil (PRED element).
>
> Indeed, what about:
>
> Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
> If so, return the first non-nil value returned by PRED.
Yeah better.
The first line with the repetition of 'non-nil' sounds a little poetic.
How about?
Return non-nil if PRED is satisfied for at least one element of SEQUENCE.
If so, return the first non-nil value returned by PRED.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 10:31 ` Tino Calancha
@ 2016-12-07 12:31 ` Nicolas Petton
2016-12-07 16:16 ` Eli Zaretskii
2016-12-07 16:57 ` Pierre Lorenzon
2 siblings, 0 replies; 9+ messages in thread
From: Nicolas Petton @ 2016-12-07 12:31 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25129, 25129-done, Tino Calancha
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
Tino Calancha <tino.calancha@gmail.com> writes:
> The first line with the repetition of 'non-nil' sounds a little poetic.
> How about?
> Return non-nil if PRED is satisfied for at least one element of SEQUENCE.
> If so, return the first non-nil value returned by PRED.
Is poetic bad? ;-)
I'll apply your version, so I'm closing this issue.
Cheers,
Nico
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 10:31 ` Tino Calancha
2016-12-07 12:31 ` Nicolas Petton
@ 2016-12-07 16:16 ` Eli Zaretskii
2016-12-07 16:57 ` Pierre Lorenzon
2 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2016-12-07 16:16 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25129, nicolas
> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 7 Dec 2016 19:31:41 +0900 (JST)
> Cc: 25129@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
>
> > Indeed, what about:
> >
> > Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
> > If so, return the first non-nil value returned by PRED.
> Yeah better.
> The first line with the repetition of 'non-nil' sounds a little poetic.
> How about?
> Return non-nil if PRED is satisfied for at least one element of SEQUENCE.
> If so, return the first non-nil value returned by PRED.
My suggestion:
Call PRED on elements of SEQUENCE and return first non-nil value it returns.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 8:48 ` Nicolas Petton
2016-12-07 10:19 ` Tino Calancha
@ 2016-12-07 16:28 ` Pierre Lorenzon
1 sibling, 0 replies; 9+ messages in thread
From: Pierre Lorenzon @ 2016-12-07 16:28 UTC (permalink / raw)
To: nicolas; +Cc: 25129
From: Nicolas Petton <nicolas@petton.fr>
Subject: Re: bug#25129: 26.0.50; seq-some function
Date: Wed, 07 Dec 2016 09:48:29 +0100
> Pierre Lorenzon <devel@pollock-nageoire.net> writes:
>
> Hi Pierre,
>
>> I well understand now that I must use seq-find instead of
>> seq-some but I think that I will not be the only one being
>> confused by these functions specifications !
>
> There is a mistake (extra if) in the documentation, I will fix that.
Good !
>
> Other than that, is the following less confusing?
>
> Return non-nil if PRED returns non-nil for at least one element of SEQUENCE.
> If so, return the value returned by PRED.
Yes this is absolutely clear now from my point of view.
I know taht this function has been first called seq-some-p
then seq-(some and its spec has maybe changed as well. But
now with your new documentation I htink that documentation
fit function behavior. That's only what we need. The fact
that function fit our own need is another question : in
fact seq-find does !
Thanks !
Pierre
>
> Cheers,
> Nico
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#25129: 26.0.50; seq-some function
2016-12-07 10:31 ` Tino Calancha
2016-12-07 12:31 ` Nicolas Petton
2016-12-07 16:16 ` Eli Zaretskii
@ 2016-12-07 16:57 ` Pierre Lorenzon
2 siblings, 0 replies; 9+ messages in thread
From: Pierre Lorenzon @ 2016-12-07 16:57 UTC (permalink / raw)
To: tino.calancha; +Cc: 25129, nicolas
From: Tino Calancha <tino.calancha@gmail.com>
Subject: Re: bug#25129: 26.0.50; seq-some function
Date: Wed, 7 Dec 2016 19:31:41 +0900 (JST)
>
>
> On Wed, 7 Dec 2016, Nicolas Petton wrote:
>
>> Tino Calancha <tino.calancha@gmail.com> writes:
>>
>>> Nicolas Petton <nicolas@petton.fr> writes:
>>>
>>>> Pierre Lorenzon <devel@pollock-nageoire.net> writes:
>>>>
>>>> Hi Pierre,
>>>>
>>>>> I well understand now that I must use seq-find instead of
>>>>> seq-some but I think that I will not be the only one being
>>>>> confused by these functions specifications !
>>>>
>>>> There is a mistake (extra if) in the documentation, I will fix
>>>> that.
>>>>
>>>> Other than that, is the following less confusing?
>>>>
>>>> Return non-nil if PRED returns non-nil for at least one element
>>>> of SEQUENCE.
>>>> If so, return the value returned by PRED.
>>
>>> The previous doc string contains more information: it
>>> explicitely says
>>> that it returns the _first_ non-nil (PRED element).
>>
>> Indeed, what about:
>>
>> Return non-nil if PRED returns non-nil for at least one element
>> of SEQUENCE.
>> If so, return the first non-nil value returned by PRED.
> Yeah better.
> The first line with the repetition of 'non-nil' sounds a little
> poetic.
> How about?
> Return non-nil if PRED is satisfied for at least one element of
> SEQUENCE.
> If so, return the first non-nil value returned by PRED.
OK that is in fact more precise.
Pierre
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-12-07 16:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-07 8:09 bug#25129: 26.0.50; seq-some function Pierre Lorenzon
2016-12-07 8:48 ` Nicolas Petton
2016-12-07 10:19 ` Tino Calancha
2016-12-07 10:24 ` Nicolas Petton
2016-12-07 10:31 ` Tino Calancha
2016-12-07 12:31 ` Nicolas Petton
2016-12-07 16:16 ` Eli Zaretskii
2016-12-07 16:57 ` Pierre Lorenzon
2016-12-07 16:28 ` Pierre Lorenzon
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).