Skip to main content
8 events
when toggle format what by license comment
Mar 25, 2020 at 11:37 comment added Joe Bentley Thanks, this looks good, although I probably won't end up using it due to its verbosity :) I'm using Mathematica 12.1.0.0 for reference
Mar 25, 2020 at 11:35 vote accept Joe Bentley
Mar 24, 2020 at 20:58 comment added Mr.Wizard Thanks. On the second point where does a naive Replace[defalt, pattern | _ :> RHS] type of construct fail? Is it in handling multiple arguments? E.g. Replace[g[10], y : (g[x_] | _) :> {y, x}] and Replace[{1, 2, 3}, y : (g[x_] | _) :> {y, x}] both fill {y, x} in what to me seams a reasonable way.
Mar 24, 2020 at 19:16 comment added Itai Seggev Re (1) I'm not sure if this is documented. I'll put it on my doc review list to check. (2) I don't have a great answer for this. It is most likely possible in principle, though there is a question of whether the cost and risk is justified. One thing we did discover when this came up was even in the old code, if the pattern was sufficiently complicated, we might not get all the inner bindings correct (oops). Never doing it is certainly easier to implement, and it is much better to document "never" than "sometimes but we won't tell you when".
Mar 24, 2020 at 6:45 comment added Mr.Wizard (1) This is a potentially code-breaking change; is it documented? The relaxation was raised in (108636) and it made sense to me at the time, but I hadn't realized what was lost. (2) What is the reason that the pattern binding cannot happen when the default does match? That would seem to be the best of both worlds, without giving this the thought it is probably due.
Mar 24, 2020 at 6:36 comment added Itai Seggev You're right, it did change. Probably in 10.x? I'd have go testing versions to be sure. In earlier versions, it was required that the default value match the pattern. It was often requested that we relax this requirement. When we did so, we lost the ability to bind x_ to the default. Based on the number of complaints we've gotten about the change, I think we made the right call with this compromise, but there are edge cases like this one where it is somewhat unfortunate.
Mar 24, 2020 at 6:14 comment added Mr.Wizard Am I right in thinking that this behavior has changed? I think in version 7 the x_ in f[y:g[x_]:g[10]] := {y, x}; did bind to 10?
Mar 24, 2020 at 5:36 history answered Itai Seggev CC BY-SA 4.0