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

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

Re: Function argument order of evaluation


From: Tadeus Prastowo
Subject: Re: Function argument order of evaluation
Date: Mon, 11 Feb 2019 16:15:14 +0100

On Mon, Feb 11, 2019 at 4:01 PM YUE Daian <sheepduke@gmail.com> wrote:
>
> On 2019-02-11 10:53, Tadeus Prastowo <tadeus.prastowo@unitn.it> wrote:
> > Hello,
> >
> > In C/C++, the following code has an undefined behavior (UB):
> >
> > int my_var = 1;
> > my_function((my_var = 10), 2 * my_var);
> >
> > It is because their respective standards do not specify that the
> > assignment `(my_var = 10)' as the first argument must be evaluated
> > before the second argument `2 * my_var' is evaluated.  So,
> > `my_function' can see as its arguments either `10' and `20' or `10'
> > and `2'.

[...]

> Hi Tadeus,

Hi Danny,

> From the Emacs Lisp reference:
> ...then the forms in the function body are evaluated in order, and the
> value of the last body form becomes the value of the function call.
>
> You see, the forms in the function body are evaluated *in order*.
>
> I think it can be treated as a guarantee? ;-)

Thank you for responding.  But, my question is not about the
evaluation of the function body but about the invocation of the
function itself.

> Reference:
> https://ftp.gnu.org/old-gnu/Manuals/elisp-manual-20-2.5/html_chapter/elisp_9.html#SEC114
>
> Danny

--
Best regards,
Tadeus



reply via email to

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