1
$\begingroup$

Is it better to use pure Function assigned to symbols as their OwnValues vs function defined by patterns as symbol's DownValues.

Which one is faster and are there any exceptions?

$\endgroup$
3
  • 4
    $\begingroup$ Pure functions are often a bit faster, but defining functions by patterns as DownValues is more flexible. For example, this allows for overloading of functions and in combination with TagSetDelayed, you an implement your own "classes" (in the sense of object oriented programming). $\endgroup$ Jun 13, 2018 at 22:23
  • 2
    $\begingroup$ there is no better or worse, they have different use cases, Henriks comment only mentions some of the differences. I'm quite confident that you can find exceptions to the speed question as well :-) $\endgroup$ Jun 13, 2018 at 23:04
  • 1
    $\begingroup$ I also believe your question is completely answered by the one that @xzczd linked. $\endgroup$
    – halirutan
    Jun 14, 2018 at 2:13

0

Browse other questions tagged or ask your own question.