* Use of return in dolist
@ 2024-12-31 18:45 Heime via Users list for the GNU Emacs text editor
2025-01-01 4:31 ` Joel Reicher
0 siblings, 1 reply; 7+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-12-31 18:45 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
I want to understand what return does? I is supposed to exit the dolist.
But does return also return a value. Does in also exit the function or not?
(defun amazones-okul-kntlr (actm-seqr)
"TODO"
;; Make ACTM-SEQR a list, even if a single symbol is passed.
(let ( (actm-seqr
(if (listp actm-seqr) actm-seqr (list actm-seqr))) )
(dolist (actm actm-seqr)
(pcase actm
;; PCASE
('armg
(message "ARMG amazones-okul-kntlr")
(add-to-list 'load-path (amazones-fpln-waypt "OKUL" 'sec))
(require 'okul)
(require 'prevodilac))
;; PCASE
('go
(message "GO amazones-okul-kntlr")
(okul-modeline "primitive"))
;; PCASE
('nogo
(message "NOGO amazones-okul-kntlr")
(return))
;; PCASE
(_
(message "NOGO amazones-okul-kntlr")
(message " └── ACTM Unrecognised: %s" actm)
(return)) ))) )
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2024-12-31 18:45 Use of return in dolist Heime via Users list for the GNU Emacs text editor
@ 2025-01-01 4:31 ` Joel Reicher
2025-01-01 23:09 ` Heime via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 7+ messages in thread
From: Joel Reicher @ 2025-01-01 4:31 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime
Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> I want to understand what return does? I is supposed to exit
> the dolist. But does return also return a value. Does in also
> exit the function or not?
What does the documentation or definition for it say?
Regards,
- Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2025-01-01 4:31 ` Joel Reicher
@ 2025-01-01 23:09 ` Heime via Users list for the GNU Emacs text editor
2025-01-02 0:28 ` Joel Reicher
2025-01-02 0:42 ` Eduardo Ochs
0 siblings, 2 replies; 7+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2025-01-01 23:09 UTC (permalink / raw)
To: Joel Reicher; +Cc: Heime via Users list for the GNU Emacs text editor
Sent with Proton Mail secure email.
On Wednesday, January 1st, 2025 at 4:31 PM, Joel Reicher <joel.reicher@gmail.com> wrote:
> Heime via Users list for the GNU Emacs text editor
> help-gnu-emacs@gnu.org writes:
>
> > I want to understand what return does? I is supposed to exit
> > the dolist. But does return also return a value. Does in also
> > exit the function or not?
>
>
> What does the documentation or definition for it say?
>
> Regards,
>
> - Joel
I cannot do C-h f return
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2025-01-01 23:09 ` Heime via Users list for the GNU Emacs text editor
@ 2025-01-02 0:28 ` Joel Reicher
2025-01-02 0:42 ` Eduardo Ochs
1 sibling, 0 replies; 7+ messages in thread
From: Joel Reicher @ 2025-01-02 0:28 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
Heime <heimeborgia@protonmail.com> writes:
> On Wednesday, January 1st, 2025 at 4:31 PM, Joel Reicher
> <joel.reicher@gmail.com> wrote:
>
>> Heime via Users list for the GNU Emacs text editor
>> help-gnu-emacs@gnu.org writes:
>>
>>> I want to understand what return does? I is supposed to exit
>>> the dolist. But does return also return a value. Does in also
>>> exit the function or not?
>>
>> What does the documentation or definition for it say?
>
> I cannot do C-h f return
That would suggest the function doesn't exist at all. Doesn't the
code give an error? Is it your code, and if so why did you write
"(return)"?
Regards,
- Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2025-01-01 23:09 ` Heime via Users list for the GNU Emacs text editor
2025-01-02 0:28 ` Joel Reicher
@ 2025-01-02 0:42 ` Eduardo Ochs
2025-01-02 1:21 ` Eduardo Ochs
1 sibling, 1 reply; 7+ messages in thread
From: Eduardo Ochs @ 2025-01-02 0:42 UTC (permalink / raw)
To: Heime; +Cc: Joel Reicher, Heime via Users list for the GNU Emacs text editor
On Wed, 1 Jan 2025 at 20:10, Heime via Users list for the GNU Emacs
text editor <help-gnu-emacs@gnu.org> wrote:
>
> I cannot do C-h f return
Try:
(defun eek (str) (execute-kbd-macro (read-kbd-macro str)))
(eek "M-x apropos RET return RET")
(eek "C-h f cl-return RET")
Cheers,
Eduardo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2025-01-02 0:42 ` Eduardo Ochs
@ 2025-01-02 1:21 ` Eduardo Ochs
2025-01-02 10:44 ` Jean Louis
0 siblings, 1 reply; 7+ messages in thread
From: Eduardo Ochs @ 2025-01-02 1:21 UTC (permalink / raw)
To: Heime; +Cc: Joel Reicher, Heime via Users list for the GNU Emacs text editor
On Wed, 1 Jan 2025 at 21:42, Eduardo Ochs <eduardoochs@gmail.com> wrote:
>
> On Wed, 1 Jan 2025 at 20:10, Heime via Users list for the GNU Emacs
> text editor <help-gnu-emacs@gnu.org> wrote:
> >
> > I cannot do C-h f return
>
> Try:
>
> (defun eek (str) (execute-kbd-macro (read-kbd-macro str)))
> (eek "M-x apropos RET return RET")
> (eek "C-h f cl-return RET")
>
> Cheers,
> Eduardo
Try this too:
;; See: (info "(cl)Blocks and Exits")
(defun myinsert (o) (insert (format "\n%S" o)))
(dolist (i '(2 3 5)) (myinsert i))
(cl-block nil (dolist (i '(2 3 5 8)) (if (= i 5) (cl-return) (myinsert i))))
Cheers,
E.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use of return in dolist
2025-01-02 1:21 ` Eduardo Ochs
@ 2025-01-02 10:44 ` Jean Louis
0 siblings, 0 replies; 7+ messages in thread
From: Jean Louis @ 2025-01-02 10:44 UTC (permalink / raw)
To: Eduardo Ochs
Cc: Heime, Joel Reicher,
Heime via Users list for the GNU Emacs text editor
* Eduardo Ochs <eduardoochs@gmail.com> [2025-01-02 04:23]:
> Try this too:
>
> ;; See: (info "(cl)Blocks and Exits")
> (defun myinsert (o) (insert (format "\n%S" o)))
> (dolist (i '(2 3 5)) (myinsert i))
2
3
5
> (cl-block nil (dolist (i '(2 3 5 8)) (if (= i 5) (cl-return) (myinsert i))))
2
3
I have tried the above by using M-e evaluation after M-x eev-beginner RET
I am fan of `while`:
;; this one
(let ((i '(2 3 5 8))
(no-go t))
(while no-go
(let ((item (pop i)))
(cond ((= item 5) (setq no-go nil))
(t (insert (format "\n%S" item)))))))
2
3
;; Or this one:
(let ((i '(2 3 5 8)))
(while (and i (not (= (car i) 5)))
(insert (format "\n%S" (car i)))
(setq i (cdr i))))
2
3
--
Jean Louis
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-01-02 10:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-31 18:45 Use of return in dolist Heime via Users list for the GNU Emacs text editor
2025-01-01 4:31 ` Joel Reicher
2025-01-01 23:09 ` Heime via Users list for the GNU Emacs text editor
2025-01-02 0:28 ` Joel Reicher
2025-01-02 0:42 ` Eduardo Ochs
2025-01-02 1:21 ` Eduardo Ochs
2025-01-02 10:44 ` Jean Louis
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).