Timeline for Protecting function definitions only for particular inputs
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 25, 2013 at 10:59 | vote | accept | Timothy Wofford | ||
Oct 20, 2013 at 20:52 | comment | added | Rojo |
@TimothyWofford as far as I know ValueFunction is for OwnValues only, but my memory may be wrong
|
|
Oct 20, 2013 at 20:44 | comment | added | Timothy Wofford |
@Rojo, I haven't abandoned this question. Your example gives the default behavior of passing the rhs on to the next calculation and effectively not changing the protected values. But it doesn't send a warning. @Leonid's solution only works against changes caused by Set. I recently came across ValueFunction in the Experimental context, which may show some promise.
|
|
Sep 11, 2013 at 0:15 | comment | added | Mr.Wizard |
You shouldn't be apologizing for your avant-garde code. This is great stuff. Anyway, you seem to have a better handle on caching than I do; after all guard is your trick. It would be nice if there was some way that f would only be re-evaluated when a change was made that affected the value of f , but I don't know how to go about it.
|
|
Sep 10, 2013 at 23:46 | comment | added | Rojo | @Mr.Wizard as to the speed I wasn't too hopeful from the start, but perhaps there's hope? | |
Sep 10, 2013 at 23:45 | comment | added | Rojo | Now the definitions don't get accumulated, but the equations do get all accumulated | |
Sep 10, 2013 at 23:43 | comment | added | Rojo | @Mr.Wizard look what happens when I try to clean up. I gave up on trying not to use non-built-ins. Feel free to edit. | |
Sep 10, 2013 at 23:43 | history | edited | Rojo | CC BY-SA 3.0 |
added 398 characters in body
|
Sep 10, 2013 at 23:39 | comment | added | Mr.Wizard | There is a downside to this: the overhead is higher than I expected. I thought that caching would take place so that the restore would not be done repeatedly but that does not appear to be the case. This slows a simple hash-table function by an order of magnitude. | |
Sep 10, 2013 at 23:32 | comment | added | Rojo | @Mr.Wizard, ok, since you liked the proof of concept, I'll remove the "lamer" qualifier and clean that up | |
Sep 10, 2013 at 23:29 | comment | added | Mr.Wizard |
A new definition (with overhead) is created every time fix is used, even if it's used for the same Set. I'd like to see that cleaned up. We should only ever need one definition for f .
|
|
Sep 10, 2013 at 23:25 | comment | added | Mr.Wizard |
I quite like this approach. With effort one could create a situation where the DownValues of f do not show the value you want because f itself was never evaluated, but that seems like quite an edge case. Otherwise I think this method is robust and practical.
|
|
Sep 10, 2013 at 23:16 | comment | added | Mr.Wizard | You are illustrating my failure of imagination. This is quite tricky however. :-) | |
Sep 10, 2013 at 23:07 | history | answered | Rojo | CC BY-SA 3.0 |