help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does pcase need progn in if condition


From: Emanuel Berg
Subject: Re: Does pcase need progn in if condition
Date: Sat, 22 May 2021 11:32:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jean Louis wrote:

> `progn` returns the the last value:

The nth value...

> [progn] is better looking then `let` when empty:
>
> (let ()
>   (message "hello")
>   '(do-more)
>   emacs-build-number) ⇒ 1

Your example :)

> `prog1' is very handy as it will not return the last value
> but the value from 1st form:

:)

> Example is when you wish to return a value and after that
> informa a user like here below:
>
> (cond ((= a 1) (do-something))
>       (t (prog1 nil (message "Query shall be longer..."))))

...

> After returning `report' it will message user about it.
> Maybe you wish to return the status of a function and
> continue informing user?
>
> (defun function ()
>   "Return REPORT"
>   (prog1
>       report
>     (message report))) 

But you can do that with `let' as well and besides ... message
already does that? :O

(message "Oh, baby!") ; "Oh, baby!"

?

> And `prog2' is more than this, it will return the value from
> 2nd form, not third or first.

Some Elisp for you:

  cl-prog
  cl-prog*
  cl-progv
  cl-tagbody

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]