emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase defuns


From: Andrew Hyatt
Subject: Re: pcase defuns
Date: Sun, 27 Mar 2022 14:17:24 -0400

On Sun, Mar 27, 2022 at 05:31 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
(defun-pattern fibonacci "Compute the fibonacci sequence." ((0) 0) ((1) 1) ((n) (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))

If you go and benchmark this function, you'll see that its performance sucks even more than the usual naive fibonacci that it appears to be implementing.

Sure, I believe that. If you macroexpand-1 this, you'll see that it's implemented with pcase in a pretty straighforward manner, so this isn't adding overhead beyond pcase's, I believe. My example is about showing how the defun-pattern looks in practice, not recommending that using it for computation-intensive functions is a particularly good idea.

I see this as trading performance for clarity. Now that you mention it, I'll note this in the docstring.


        Stefan



reply via email to

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