Timeline for When should I, and when should I not, set the HoldAll attribute on a function I define?
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:55 | history | edited | CommunityBot |
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
|
|
Apr 12, 2012 at 21:13 | vote | accept | Michael Underwood | ||
Apr 12, 2012 at 3:50 | answer | added | amr | timeline score: 17 | |
Apr 11, 2012 at 20:56 | comment | added | Albert Retey |
@MichaelUnderwood: I've just seen that Timo has edited his question explaining how HoldAll is needed for the two examples, is that answering your question? And yes, of course it's good to have exceptional examples here, it just probably makes you think HoldAll is necessary more often than it actually is. Usually you will know when to use it, since when needed things will just not work without it.
|
|
Apr 11, 2012 at 19:09 | history | edited | Michael Underwood | CC BY-SA 3.0 |
Added further definition of the question.
|
Apr 11, 2012 at 18:52 | comment | added | Michael Underwood |
@Szabolcs my question includes two examples on this site where I think HoldAll is unnecessary... @Albert, it does make sense that many examples here are exceptional! Perhaps an explanation of why HoldAll is needed would help to enlighten me. I took the first example I mentioned, syntax highlighting, and entered the code from the accepted answer except for the SetAttributes line. The result was exactly what was specified it would be in the answer; I see no different behaviour in the syntax highlighting. I'm not sure why I can't then conclude that the line of code I omitted is unnecessary.
|
|
Apr 11, 2012 at 8:36 | comment | added | Albert Retey |
While it is true that in both examples you are giving there is no comment on why it is there it is not true that HoldAll is unnecessary. In fact it is necessary in both cases you mentioned and the code shown would not work without it. In general I would aggree that setting HoldAll would be the exception, but probably among the answers on this site here there are an unusual fraction of exceptional examples :-).
|
|
Apr 11, 2012 at 7:30 | comment | added | Szabolcs |
Can you give some example from this site where you think HoldAll is unnecessary? Then we can think about why it was a good idea to use it there, maybe even find out that it is in fact necessary to handle all cases.
|
|
Apr 11, 2012 at 6:14 | answer | added | Timo | timeline score: 22 | |
Apr 11, 2012 at 4:51 | history | asked | Michael Underwood | CC BY-SA 3.0 |