On Mon, Nov 2, 2009 at 6:48 AM, Jason Grout <jason-s...@creativetrax.com> wrote: > > William Stein wrote: >> On Sun, Nov 1, 2009 at 11:09 PM, Stan Schymanski <schym...@gmail.com> wrote: >>> I would love to have a script that converts old names in a whole >>> worksheet to new names. Every time someone deprecates an old name, he >>> could add the relevant line to the script. >>> >>> Would that be possible? What I would love even more, is a notebook >>> conversion function such as the one that converted my old notebook to >>> the sage 4.2 format, but I suppose this is not possible for more >>> complicated changes than just names. MMA asks the user to "Scan notebook >>> for possible issues" if you open an old notebook with a new version of >>> MMA, but this is not always helpful. >> >> Wow, this is the most interesting suggestion I've heard so far related >> to deprecation and renaming of functions in Sage. It would be great >> if we had a framework for doing the above... if it's possible. It's >> hard to imagine how it could be though, given how incredibly dynamic >> Python is. It seems like the easiest thing is to just run your code >> and view the deprecation warnings that are emitted. This would work >> so long as we never remove anything we deprecate, which seems silly. >> >> So, it would be cool to have something like you describe, but I have >> no idea how to implement it, or even if it is possible. > > > Could we use the compiler module > (http://docs.python.org/library/compiler.html) to parse the file and > walk the nodes in the ast, replacing or modifying things as needed? >
Because of "duck typing" I don't see how such an approach can ever work. Suppose a I write a function like this: def f(n): return n.squarefree_part() Right now, squarefree_part is a method of some things, e.g., integers. It _could_ also be a method of polynomials (it isn't now, but imagine it is). Suppose that it is a method on say 5 different types of objects in Sage. Suppose we deprecate it as a method on integers. Now I run that through some script that is supposed to tell me if the above code needs to be changed. It's tricky, because it *does* need to change if n is an integer, but it better not change if n is a polynomial. Regarding deprecation, we already hashed this out in a previous thread quite some time ago. * Use the official deprecation(...) function when deprecating a function. * We can tell precisely what is deprecated and when by simply looking at the source code and using the revision control system and/or comments in the source code. Thus it's completely unnecessary bureaucracy to require people to open extra tickets just for this, as was suggested elsewhere in this thread. * After one year we are allowed to remove deprecated code, but we only actually do so at major releases (e.g., 5.0, 6.0, 7.0 etc.) Thus Sage-5.0 *will* remove deprecated code that was deprecated at least a year ago. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---