On May 27, 2008, at 3:20 PM, Dag Sverre Seljebotn wrote: > >>> - Some fixes Robert pointed me to (for TreeFragment / ExprStatNode) >> >> The SubstitutionTransform still needs to be able to handle multiple >> substitutions in one pass--e.g. to do stuff like a -> b, b -> c, and >> c -> a. > > Ahh... I didn't have that goal at all, in fact I want to avoid > this. (Or > am I missing something here? Please elaborate, it's not clear to me > what > you want to achieve.) > > If my guess it right, perhaps the fix is a rename to > TemplateTransform, > and then we can have another SubstitutionTransform doing what you > want if > needed? > > Remember that the usecase is for TreeFragment: > > def complicated_create_assignment(varname, expr): > result = TreeFragment("LEFT = RIGHT").substitute({"LEFT" : > NameNode(varname), "RIGHT" : expr}) > > So, if "RIGHT" is passed as varname, your suggestion would make "expr" > appear on both sides, *not* what was intended! (and what happens if > passing "LEFT" as varname -- infinite recursion?_
Looking at your code again, I can see that I totally mis-read your code. For some reason it looked like you were only doing one substitution at a time, but "substitute" is supposed to be a dictionary so that's not the case at all. Sorry. On that node, however, this should probably be renamed to "subsitutions" to make it clearer, and there should be at least some documentation. Other that that, it looks good. > (However, it should properly assign pos to substituted nodes (which it > does not), I'll try to remember to do that next time I'm coding.) Yes, for sure. - Robert _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev