"Deprecation.st: A warning about calling deprecated methods. Copyright (C) 2007 Stephen Compall. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA" "Commentary I include a brief Warning class called Deprecation and a method on Object. You can put self deprecate: 'use keysAndValuesDo: instead'. at the beginning of deprecated methods, and on their first call, a Deprecation will be signalled with the message given. This could be sped up by using Presource to put a cookie in every self deprecate: send, but you shouldn't use deprecated methods anyway." "Code" Warning subclass: #Deprecation instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Language-Exceptions' ! Deprecation class instanceVariableNames: 'usedMethods'! Deprecation comment: 'I am signalled by methods that want to report that they shouldn''t be called anymore.' ! !Deprecation class methodsFor: 'signalling'! deprecate: aMethod reporting: aString "If I have not signalled a Deprecation for aMethod yet, signal one now, adding aString as an additional note." ^(usedMethods includes: aMethod) ifFalse: [usedMethods add: aMethod. self signal: ('%1 is deprecated: %2' bindWith: aMethod with: aString)] ! ! !Deprecation class methodsFor: 'initialization'! initialize super initialize. usedMethods := WeakIdentitySet new. ! ! !Smalltalk.Object methodsFor: 'deprecating'! deprecate: message "Deprecate the sending method, including message in the warning text if any is given." ^Deprecation deprecate: thisContext sender method reporting: message ! ! Deprecation initialize! "Deprecation.st ends here"