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

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

Re: Executing part of the code instead of another


From: tomas
Subject: Re: Executing part of the code instead of another
Date: Wed, 7 Oct 2020 16:01:50 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Oct 07, 2020 at 03:48:51PM +0200, Christopher Dimech wrote:
> It would be better if you explain to me this progn stuff
> 
> Have tried an example like this
> 
> (setq na 8)
> (setq nb 13)
> ( if (> nb na)
>     progn (
>       (message "nb > na condition [condition is true]")
>       (message "nb > na condition [condition is true]")
>     )

No. Written in Lisp, it's

  (progn
    (thing 1)
    (thing 2)
    ...)

In C (and in conventional maths, you'd write it as you did
above).

Note that it's the same way as you write (message "foo")
[you don't write message("foo"), as you'd do in C or
Python or what not).

Progn is a form to bundle a sequence of forms, which are
evaluated one after the other. The value of progn is
that of the last form evaluated (that's the -n), as opposed
to prog1, which would do the same as progn, but return the
value of its first form.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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