|
From: | Andrew Hyatt |
Subject: | Re: pcase defuns |
Date: | Sun, 27 Mar 2022 14:17:24 -0400 |
(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
[Prev in Thread] | Current Thread | [Next in Thread] |