Skip to main content
8 events
when toggle format what by license comment
Sep 11, 2013 at 9:15 comment added Timothy Wofford @Mr.Wizard However, there is that sticking point of writing a "more complex pattern" which makes point #2 "easy to fix". Would anyone care to fill in this gap?
Sep 11, 2013 at 9:14 comment added Timothy Wofford @Leonid Shifrin I agree with Leonid on both points.
Sep 10, 2013 at 23:13 comment added Leonid Shifrin @Mr.Wizard Thanks, good points. As you said, the #2 is fixable by using a more complex pattern. As to #1, I am not sure it needs changing, since obviously such an assignment is a bug / error within this approach, so isolating only that particular assignment might not make much sense. However, one way out would be to explicitly evaluate the rest of assignments before throwing an exception, picking the code for them by destructuring the code taken from the stack.
Sep 10, 2013 at 23:09 comment added Mr.Wizard I haven't yet become comfortable using Stack[] and friends. I should work on that. Anyway, I see two problems with this: (1) you prevent all assignments in the list form, rather than only the protected one; (2) your pattern is not general enough lists can be nested deeper: your present code fails with {{f[x0]}, f[x1], f[x2]} = {{q}, r, s}; I think #2 is easy to fix, but what about #1?
Sep 10, 2013 at 23:00 comment added Leonid Shifrin @Rojo This seems problematic. The only freedom you have at the stage when you evaluate the head is to break out, and even then only through exception. Here one would need to somehow abort the current evaluation and still continue the execution. I seem to remember some continuation-like behavior I once managed to implement which seemed to do this sort of things, but right now I don't quite remember where.
Sep 10, 2013 at 23:00 comment added Rojo I actually started thinking of that because for a moment I thought that the ownvalues weren't evaluated when using the list version of set, but that made no sense, so +1 again
Sep 10, 2013 at 22:57 comment added Rojo I was thinking of a stack based approach. But then I started considering using the ownvalue to restore the fixed values instead of prevent the modification. Any ideas on that? (+1)
Sep 10, 2013 at 22:55 history answered Leonid Shifrin CC BY-SA 3.0