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

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

Re: [External] : Re: Emacs 30.0 warning from `cl-pushnew' and `memql'


From: tomas
Subject: Re: [External] : Re: Emacs 30.0 warning from `cl-pushnew' and `memql'
Date: Thu, 29 Dec 2022 07:03:40 +0100

On Thu, Dec 29, 2022 at 01:47:57AM +0300, Jean Louis wrote:

[...]

> > (And no reason to quote either () or a literal string.)
> 
> There was reason. See here:
> 
> (setq my-list '())
> (benchmark 1000 (setq my-list (cons "Word" my-list)))
> 
> Debugger entered--Lisp error: (invalid-function "Word")
>   ("Word")
>   (closure (t) nil ("Word"))()

[...]

> but then `benchmark` worked only first time, second time it gave
> error.

Read benchmark's doc string carefully :-)

Benchmark is a /function/, so its argument is evaluated first. By
the Rule of Lisp [1], args are evaluated first...

  (benchmark (cons "Word" my-list)) =>
  (benchmark ("Word")) => ; since list is empty

... and then it tries to evaluate the function application
("Word"), which explains your error message.

If now you look again at the benchmark's docstring it says to
provide a form. This means you have to quote the whole thing
like so:

  (benchmark 1000 '(setq my-list (cons "word" my-list)))

If you just quote "Word", you are benchmarking the wrong thing, anyway :)

Cheers

[1] aka "strict order evaluation"
    https://en.wikipedia.org/wiki/Evaluation_strategy#Strict_evaluation
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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