From 256976dddd95245c61b23e3e848a93d701ef23b4 Mon Sep 17 00:00:00 2001 From: jmdavis Date: Sun, 23 Oct 2011 23:11:17 -0700 Subject: [PATCH] Removed "scheduled for deprecation" pragmas. The pragmas have not been as effective as we might have liked, since they only work with templates and can't tell you where in your code you need to make changes, and they seemed to have been more annoying to programmers than helpful, so we're going to discontinue them. We'll leave them in for stuff that's actually been deprecated until deprecated has been improved enough to take a message, but we'll leave "scheduled for deprecation" messages to the documentation and changelog. --- std/algorithm.d | 5 +-- std/array.d | 13 +++----- std/conv.d | 9 ++--- std/ctype.d | 4 --- std/datetime.d | 16 --------- std/exception.d | 9 ----- std/file.d | 15 --------- std/path.d | 87 +++++++++++++++++++++++++++++-------------------- std/string.d | 29 ++--------------- std/utf.d | 11 ------- 10 files changed, 65 insertions(+), 133 deletions(-) diff --git a/std/algorithm.d b/std/algorithm.d index 466fa0fe2..cc3eab067 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -3701,6 +3701,9 @@ unittest } /** + * $(RED Scheduled for deprecation. Please use $(XREF algorithm, countUntil) + * instead.) + * * Same as $(D countUntil). This symbol has been scheduled for * deprecation because it is easily confused with the homonym function * in $(D std.string). @@ -3708,8 +3711,6 @@ unittest sizediff_t indexOf(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle) if (is(typeof(startsWith!pred(haystack, needle)))) { - pragma(msg, "std.algorithm.indexOf has been scheduled for deprecation." - " You may want to use std.algorithm.countUntil instead."); return countUntil!pred(haystack, needle); } diff --git a/std/array.d b/std/array.d index fe9679415..8fd161cb6 100644 --- a/std/array.d +++ b/std/array.d @@ -923,23 +923,20 @@ unittest } /++ - $(RED Scheduled for deprecation. Use $(XREF array, insertInPlace) instead.) + $(RED Scheduled for deprecation in November 2011. + Please use $(LREF insertInPlace) instead.) Same as $(XREF array, insertInPlace). +/ void insert(T, Range)(ref T[] array, size_t pos, Range stuff) if (isInputRange!Range && is(ElementEncodingType!Range : T)) { - pragma(msg, "std.array.insert has been scheduled for deprecation. " ~ - "Use insertInPlace instead."); insertInPlace(array, pos, stuff); } /// Ditto void insert(T)(ref T[] array, size_t pos, T stuff) { - pragma(msg, "std.array.insert has been scheduled for deprecation. " ~ - "Use insertInPlace instead."); insertInPlace(array, pos, stuff); } @@ -1747,16 +1744,14 @@ unittest } /++ - $(RED Scheduled for deprecation. Use $(XREF array, replaceInPlace) instead.) + $(RED Scheduled for deprecation in November 2011. + Please use $(LREF replaceInPlace) instead.) Same as $(XREF array, replaceInPlace). +/ void replace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff) if (isDynamicArray!Range && is(ElementType!Range : T)) { - pragma(msg, "std.array.replace(T, Range)(ref T[] array, size_t from, " ~ - "size_t to, Range stuff) has been scheduled for deprecation. " ~ - "Use replaceInPlace instead."); replaceInPlace(array, from, to, stuff); } diff --git a/std/conv.d b/std/conv.d index b3febce4a..fd4a1a8f7 100644 --- a/std/conv.d +++ b/std/conv.d @@ -351,8 +351,9 @@ unittest } /** -$(RED Scheduled for deprecation in January 2012. Please use - method $(D opCast) instead.) +$(RED Scheduled for deprecation in January 2012. Please define $(D opCast) + for user-defined types instead of a $(D to) function. + $(LREF to) will now use $(D opCast).) Object-_to-non-object conversions look for a method "to" of the source object. @@ -379,10 +380,6 @@ unittest T toImpl(T, S)(S value) if (is(S : Object) && !is(T : Object) && !isSomeString!T && is(typeof(S.init.to!T()) : T)) { - pragma(msg, "Notice: As of Phobos 2.054, std.conv.toImpl using method " ~ - "\"to\" has been scheduled for deprecation in January 2012. " ~ - "Please use method opCast instead."); - return value.to!T(); } diff --git a/std/ctype.d b/std/ctype.d index 4481258d4..abe6788a8 100644 --- a/std/ctype.d +++ b/std/ctype.d @@ -22,10 +22,6 @@ module std.ctype; import std.ascii; -pragma(msg, "Notice: As of Phobos 2.054, std.ctype has been scheduled for " ~ - "deprecation in January 2012. Please use std.ascii instead."); - - /** * $(RED Scheduled for deprecation in January 2012. Please use * $(D std.ascii.isAlphaNum) instead.) diff --git a/std/datetime.d b/std/datetime.d index f6e789921..98dbf7c51 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -8459,8 +8459,6 @@ assert(SysTime.fromISOExtString("2010-07-04T07:06:12+8:00") == static SysTime fromISOExtendedString(S)(in S isoExtString, immutable TimeZone tz = null) if(isSomeString!(S)) { - pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString")); - return fromISOExtString!string(isoExtString, tz); } @@ -13116,8 +13114,6 @@ assert(Date.fromISOExtString(" 2010-07-04 ") == Date(2010, 7, 4)); static Date fromISOExtendedString(S)(in S isoExtString) if(isSomeString!(S)) { - pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString")); - return fromISOExtString!string(isoExtString); } @@ -14735,8 +14731,6 @@ assert(TimeOfDay.fromISOExtString(" 12:30:33 ") == TimeOfDay(12, 30, 33)); static TimeOfDay fromISOExtendedString(S)(in S isoExtString) if(isSomeString!(S)) { - pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString")); - return fromISOExtString!string(isoExtString); } @@ -17976,8 +17970,6 @@ assert(DateTime.fromISOExtString(" 2010-07-04T07:06:12 ") == static DateTime fromISOExtendedString(S)(in S isoExtString) if(isSomeString!(S)) { - pragma(msg, softDeprec!("2.053", "November 2011", "fromISOExtendedString", "fromISOExtString")); - return fromISOExtString!string(isoExtString); } @@ -34133,11 +34125,3 @@ template _isPrintable(T...) enum _isPrintable = _isPrintable!(T[0]) && _isPrintable!(T[1 .. $]); } } - - -template softDeprec(string vers, string date, string oldFunc, string newFunc) -{ - enum softDeprec = Format!("Notice: As of Phobos %s, std.datetime.%s has been scheduled " ~ - "for deprecation in %s. Please use std.datetime.%s instead.", - vers, oldFunc, date, newFunc); -} diff --git a/std/exception.d b/std/exception.d index fd712ed51..4c753d44b 100644 --- a/std/exception.d +++ b/std/exception.d @@ -501,15 +501,6 @@ T enforceEx(E, T)(T value, lazy string msg = "", string file = __FILE__, size_t T enforceEx(E, T)(T value, lazy string msg = "") @safe pure if (is(typeof(new E(msg))) && !is(typeof(new E(msg, __FILE__, __LINE__)))) { - import std.metastrings; - - pragma(msg, Format!("Notice: As of Phobos 2.055, the version of enforceEx which " ~ - "constructs its exception with new E(msg) instead of " ~ - "new E(msg, file, line) has been scheduled for " ~ - "deprecation in February 2012. Please update %s's " ~ - "constructor so that it can be constructed with " ~ - "new %s(msg, file, line).", E.stringof, E.stringof)); - if (!value) throw new E(msg); return value; } diff --git a/std/file.d b/std/file.d index 1bd760ff2..e84635dba 100644 --- a/std/file.d +++ b/std/file.d @@ -937,10 +937,6 @@ else version(Posix) void getTimesPosix(C)(in C[] name, out SysTime fileModificationTime) if(is(Unqual!C == char)) { - pragma(msg, "Notice: As of Phobos 2.054, std.file.getTimesPosix has been " ~ - "scheduled for deprecation in November 2011. Please use " ~ - "the version of getTimes with two arguments instead."); - struct_stat64 statbuf = void; cenforce(stat64(toStringz(name), &statbuf) == 0, name); @@ -3602,7 +3598,6 @@ void main(string[] args) +/ string[] listDir(C)(in C[] pathname) { - pragma(msg, softDeprec!("2.054", "November 2011", "listDir", "dirEntries")); auto result = appender!(string[])(); bool listing(string filename) @@ -3674,7 +3669,6 @@ void main(string[] args) string[] listDir(C, U)(in C[] pathname, U filter, bool followSymlink = true) if(is(C : char) && !is(U: bool delegate(string filename))) { - pragma(msg, softDeprec!("2.054", "November 2011", "listDir", "dirEntries")); import std.regexp; auto result = appender!(string[])(); bool callback(DirEntry* de) @@ -3747,7 +3741,6 @@ string[] listDir(C, U)(in C[] pathname, U filter, bool followSymlink = true) void listDir(C, U)(in C[] pathname, U callback) if(is(C : char) && is(U: bool delegate(string filename))) { - pragma(msg, softDeprec!("2.054", "November 2011", "listDir", "dirEntries")); _listDir(pathname, callback); } @@ -3883,14 +3876,6 @@ version(Windows) } -template softDeprec(string vers, string date, string oldFunc, string newFunc) -{ - enum softDeprec = Format!("Notice: As of Phobos %s, std.file.%s has been scheduled " ~ - "for deprecation in %s. Please use std.file.%s instead.", - vers, oldFunc, date, newFunc); -} - - template hardDeprec(string vers, string date, string oldFunc, string newFunc) { enum hardDeprec = Format!("Notice: As of Phobos %s, std.file.%s has been deprecated " ~ diff --git a/std/path.d b/std/path.d index 0b4149308..cdc17f5a5 100644 --- a/std/path.d +++ b/std/path.d @@ -2752,15 +2752,6 @@ unittest // scheduled for deprecation in February 2012. // ============================================================================= -// Deprecation message -import std.metastrings; -private template softDeprec(string vers, string date, string oldFunc, string newFunc) -{ - enum softDeprec = Format!("Notice: As of Phobos %s, std.path.%s has been scheduled " ~ - "for deprecation in %s. Please use %s instead.", - vers, oldFunc, date, newFunc); -} - import std.algorithm, std.array, std.conv, std.file, std.process, std.string, std.traits; @@ -2822,7 +2813,10 @@ version(Posix) } } -/* **************************** +/****************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF filenameCmp) instead.) + * * Compare file names. * Returns: * @@ -2834,12 +2828,14 @@ version(Posix) int fcmp(alias pred = "a < b", S1, S2)(S1 s1, S2 s2) if (isSomeString!S1 && isSomeString!S2) { - pragma (msg, softDeprec!("2.055", "February 2012", "fcmp", "filenameCmp")); version (Windows) return std.string.icmp(s1, s2); version (Posix) return std.algorithm.cmp(s1, s2); } -/* ************************* +/*************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF extension) instead.) + * * Extracts the extension from a filename or path. * * This function will search fullname from the end until the @@ -2871,7 +2867,6 @@ int fcmp(alias pred = "a < b", S1, S2)(S1 s1, S2 s2) string getExt()(string fullname) { - pragma (msg, softDeprec!("2.055", "February 2012", "getExt", "extension")); auto i = fullname.length; while (i > 0) { @@ -2935,7 +2930,10 @@ version (OldStdPathUnittest) unittest assert(i == 0); } -/* ************************* +/*************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF stripExtension) instead.) + * * Returns the extensionless version of a filename or path. * * This function will search fullname from the end until the @@ -2967,7 +2965,6 @@ version (OldStdPathUnittest) unittest string getName()(string fullname) { - pragma (msg, softDeprec!("2.055", "February 2012", "getName", "stripExtension")); auto i = fullname.length; while (i > 0) { @@ -3009,7 +3006,10 @@ version (OldStdPathUnittest) unittest assert(i == 0); } -/* ************************* +/*************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF baseName) instead.) + * * Extracts the base name of a path and optionally chops off a * specific suffix. * @@ -3050,7 +3050,6 @@ out (result) } body { - pragma (msg, softDeprec!("2.055", "February 2012", "basename", "baseName")); auto i = fullname.length; for (; i > 0; i--) { @@ -3114,7 +3113,10 @@ version (OldStdPathUnittest) unittest assert(basename("dmd.conf"w.dup, ".conf"d.dup) == "dmd"); } -/* ************************* +/*************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF dirName) instead.) + * * Extracts the directory part of a path. * * This function will search $(D fullname) from the end until the @@ -3152,7 +3154,6 @@ version (OldStdPathUnittest) unittest Char[] dirname(Char)(Char[] fullname) if (isSomeChar!Char) { - pragma (msg, softDeprec!("2.055", "February 2012", "dirname", "dirName")); alias immutable(Char)[] ImmString; Char[] s = fullname; @@ -3348,7 +3349,10 @@ version (OldStdPathUnittest) unittest // dirname + basename } -/* ******************************* +/********************************* + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF driveName) instead.) + * * Extracts the drive letter of a path. * * This function will search fullname for a colon from the beginning. @@ -3373,7 +3377,6 @@ Char[] getDrive(Char)(Char[] fullname) if (isSomeChar!Char) // } body { - pragma (msg, softDeprec!("2.055", "February 2012", "getDrive", "driveName")); version(Windows) { foreach (i; 0 .. fullname.length) @@ -3393,7 +3396,10 @@ body } } -/* *************************** +/***************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF defaultExtension) instead.) + * * Appends a default extension to a filename. * * This function first searches filename for an extension and @@ -3416,7 +3422,6 @@ body string defaultExt()(string filename, string ext) { - pragma (msg, softDeprec!("2.055", "February 2012", "defaultExt", "defaultExtension")); string existing; existing = getExt(filename); @@ -3432,7 +3437,10 @@ string defaultExt()(string filename, string ext) } -/* *************************** +/***************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF setExtension) instead.) + * * Adds or replaces an extension to a filename. * * This function first searches filename for an extension and @@ -3457,7 +3465,6 @@ string defaultExt()(string filename, string ext) string addExt()(string filename, string ext) { - pragma (msg, softDeprec!("2.055", "February 2012", "addExt", "setExtension")); string existing; existing = getExt(filename); @@ -3477,7 +3484,10 @@ string addExt()(string filename, string ext) } -/* ************************************ +/************************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF isAbsolute) instead.) + * * Checks if path is absolute. * * Returns: non-zero if the path starts from the root directory (Linux) or @@ -3504,7 +3514,6 @@ string addExt()(string filename, string ext) bool isabs()(in char[] path) { - pragma (msg, softDeprec!("2.055", "February 2012", "isabs", "isAbsolute")); auto d = getDrive(path); version (Windows) { @@ -3537,12 +3546,14 @@ version (OldStdPathUnittest) unittest } } -/* * +/** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF absolutePath) instead.) + * * Converts a relative path into an absolute path. */ string rel2abs()(string path) { - pragma (msg, softDeprec!("2.055", "February 2012", "rel2abs", "absolutePath")); if (!path.length || isabs(path)) { return path; @@ -3578,7 +3589,10 @@ version (OldStdPathUnittest) unittest } } -/* ************************************ +/************************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF buildPath) instead.) + * * Joins two or more path components. * * If p1 doesn't have a trailing path separator, one will be appended @@ -3606,7 +3620,6 @@ version (OldStdPathUnittest) unittest string join()(const(char)[] p1, const(char)[] p2, const(char)[][] more...) { - pragma (msg, softDeprec!("2.055", "February 2012", "join", "buildPath")); if (more.length) { // more than two components present @@ -3756,7 +3769,10 @@ version (OldStdPathUnittest) unittest } -/* ******************************** +/********************************** + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF filenameCharCmp) instead.) + * * Matches filename characters. * * Under Windows, the comparison is done ignoring case. Under Linux @@ -3783,7 +3799,6 @@ version (OldStdPathUnittest) unittest bool fncharmatch()(dchar c1, dchar c2) { - pragma (msg, softDeprec!("2.055", "February 2012", "fncharmatch", "filenameCharCmp")); version (Windows) { if (c1 != c2) @@ -3806,7 +3821,10 @@ bool fncharmatch()(dchar c1, dchar c2) } } -/* *********************************** +/************************************* + * $(RED Scheduled for deprecation in February 2012. Please use + * $(LREF globMatch) instead.) + * * Matches a pattern against a filename. * * Some characters of pattern have special a meaning (they are @@ -3861,7 +3879,6 @@ in } body { - pragma (msg, softDeprec!("2.055", "February 2012", "fnmatch", "globMatch")); size_t ni; // current character in filename foreach (pi; 0 .. pattern.length) diff --git a/std/string.d b/std/string.d index 7c9b306f9..b3a8fbb02 100644 --- a/std/string.d +++ b/std/string.d @@ -193,9 +193,6 @@ version(StdDdoc) bool iswhite(dchar c); else bool iswhite(C)(C c) if(is(Unqual!C : dchar)) { - pragma(msg, softDeprec!("2.054", "January 2012", "iswhite", - "std.ascii.isWhite or std.uni.isWhite")); - return c <= 0x7F ? indexOf(whitespace, c) != -1 : (c == paraSep || c == lineSep); @@ -881,7 +878,6 @@ unittest */ S tolower(S)(S s) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "tolower", "std.string.toLower")); return toLower!S(s); } @@ -940,7 +936,6 @@ unittest */ void tolowerInPlace(C)(ref C[] s) if (isSomeChar!C) { - pragma(msg, softDeprec!("2.054", "January 2012", "tolowerInPlace", "std.string.toLowerInPlace")); toLowerInPlace!C(s); } @@ -1056,7 +1051,6 @@ unittest */ S toupper(S)(S s) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "toupper", "std.string.toUpper")); return toUpper!S(s); } @@ -1115,7 +1109,6 @@ unittest */ void toupperInPlace(C)(ref C[] s) if (isSomeChar!C) { - pragma(msg, softDeprec!("2.054", "January 2012", "toupperInPlace", "std.string.toUpperInPlace")); toUpperInPlace!C(s); } @@ -1296,9 +1289,6 @@ unittest */ S capwords(S)(S s) if (isSomeString!S) { - pragma(msg, "Notice: As of Phobos 2.054, std.string.capwords has been " ~ - "scheduled for deprecation in January 2012."); - return _capWords!S(s); } @@ -1372,13 +1362,15 @@ deprecated S repeat(S)(S s, size_t n) /************************************** + * $(RED Scheduled for deprecation in January 2012. + * Please use $(LREF, splitLines) instead.) + * * Split s[] into an array of lines, * using CR, LF, or CR-LF as the delimiter. * The delimiter is not included in the line. */ S[] splitlines(S)(S s) { - pragma(msg, softDeprec!("2.054", "January 2012", "splitlines", "std.string.splitLines")); return splitLines!S(s); } @@ -1480,7 +1472,6 @@ unittest */ String stripl(String)(String s) { - pragma(msg, softDeprec!("2.054", "January 2012", "stripl", "std.string.stripLeft")); return stripLeft!String(s); } @@ -1516,7 +1507,6 @@ S stripLeft(S)(S s) @safe pure */ String stripr(String)(String s) { - pragma(msg, softDeprec!("2.054", "January 2012", "stripr", "std.string.stripRight")); return stripRight!String(s); } @@ -1711,7 +1701,6 @@ unittest */ S ljustify(S)(S s, size_t width) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "ljustify", "std.string.leftJustify")); return leftJustify!S(s, width); } @@ -1758,7 +1747,6 @@ S leftJustify(S)(S s, size_t width, dchar fillChar = ' ') @trusted */ S rjustify(S)(S s, size_t width) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "rjustify", "std.string.rightJustify")); return rightJustify!S(s, width); } @@ -1871,8 +1859,6 @@ unittest */ S zfill(S)(S s, int width) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "zfill", - "std.string.rightJustify with a fillChar of '0'")); return rightJustify!S(s, width, '0'); } @@ -1890,7 +1876,6 @@ in } body { - pragma(msg, softDeprec!("2.055", "February 2012", "insert", "std.array.insertInPlace")); std.array.insertInPlace(s, index, sub); return s; } @@ -1905,7 +1890,6 @@ body */ S expandtabs(S)(S str, size_t tabsize = 8) if (isSomeString!S) { - pragma(msg, softDeprec!("2.054", "January 2012", "expandtabs", "std.string.detab")); return detab!S(str, tabsize); } @@ -4045,13 +4029,6 @@ unittest } } -private template softDeprec(string vers, string date, string oldFunc, string newFunc) -{ - enum softDeprec = Format!("Notice: As of Phobos %s, std.string.%s has been scheduled " ~ - "for deprecation in %s. Please use %s instead.", - vers, oldFunc, date, newFunc); -} - private template hardDeprec(string vers, string date, string oldFunc, string newFunc) { enum hardDeprec = Format!("Notice: As of Phobos %s, std.string.%s has been deprecated " ~ diff --git a/std/utf.d b/std/utf.d index 1370c7a15..bac31d7d7 100644 --- a/std/utf.d +++ b/std/utf.d @@ -35,9 +35,6 @@ version(unittest) import std.string; } -//Remove when softDeprec and hardDeprec have been removed. -import std.metastrings; - /++ Exception thrown on errors in std.utf functions. @@ -1747,11 +1744,3 @@ unittest assert(count("abc") == 3); assert(count("\u20AC100") == 4); } - - -template softDeprec(string vers, string date, string oldFunc, string newFunc) -{ - enum softDeprec = Format!("Notice: As of Phobos %s, std.utf.%s has been scheduled " ~ - "for deprecation in %s. Please use std.utf.%s instead.", - vers, oldFunc, date, newFunc); -}