Timeline for Why is the first argument of the SetDelayed evaluated?
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 28, 2017 at 3:31 | history | edited | xzczd♦ |
edited tags
|
|
Sep 29, 2015 at 12:41 | comment | added | Leonid Shifrin | @Szabolcs This is one of them. Another one, which is IMO no less important, is that keeping l.h.s. entirely unevaluated would often lead to discrepancy between l.h.s. in definition and actual l.h.s. of a typical function call involving a given symbol, in case if such l.h.s. evaluates non-trivially - because otherwise in one case, it would evaluate, and in the other, it wouldn't. In other words, the current policy tries to make evaluation during function calls be maximally consistent with evaluation during assignments. | |
Sep 29, 2015 at 10:32 | comment | added | Szabolcs | Check out the updated answer. I believe this is the reason behind the design. | |
Sep 27, 2015 at 22:37 | history | tweeted | twitter.com/#!/StackMma/status/648265277633859584 | ||
Sep 26, 2015 at 21:16 | answer | added | Szabolcs | timeline score: 6 | |
Sep 26, 2015 at 16:52 | answer | added | Michael E2 | timeline score: 10 | |
Sep 26, 2015 at 16:23 | answer | added | Rojo | timeline score: 7 | |
Sep 26, 2015 at 16:22 | history | edited | Szabolcs |
edited tags
|
|
Sep 26, 2015 at 16:20 | comment | added | Leonid Shifrin |
I have a rather detailed discussion of evaluation during assignments here. Basically, HoldAll simply means that arguments are passed to the function in unevaluated form, but does not restrict what functions decide to do with them. And Set and SetDelayed do evaluate their first arguments, albeit in a special way. An example very similar to yours I also considered in this answer, in the section named "Evaluation: OwnValues".
|
|
Sep 26, 2015 at 16:04 | comment | added | Rolf Mertig |
Because HoldAll is documented to not do nothing, but something. If you do SetDelayed[Unevaluated[f][x_], x^2]; you will get what you want.
|
|
Sep 26, 2015 at 15:16 | comment | added | bbgodfrey | Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. | |
Sep 26, 2015 at 15:16 | history | edited | bbgodfrey | CC BY-SA 3.0 |
improved formatting
|
Sep 26, 2015 at 15:01 | review | First posts | |||
Sep 26, 2015 at 15:17 | |||||
Sep 26, 2015 at 14:54 | history | asked | XiaoaiX | CC BY-SA 3.0 |