1

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?

user13892
  • 9,375
  • 1
  • 13
  • 41
  • 4
    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). – Henrik Schumacher Jun 13 '18 at 22:23
  • 2
    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 :-) – Albert Retey Jun 13 '18 at 23:04
  • 1
    I also believe your question is completely answered by the one that @xzczd linked. – halirutan Jun 14 '18 at 02:13

0 Answers0