Thread overview
[Issue 8141] New: Two small improvements for std.string maketrans and translate
May 29, 2012
Jonathan M Davis
Dec 26, 2012
yebblies
May 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8141

           Summary: Two small improvements for std.string maketrans and
                    translate
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-05-24 14:30:14 PDT ---
A small documentation bug report and a little related enhancement request.

This is part of the std.string Phobos module:


/************************************
 * $(RED Scheduled for deprecation in March 2012.)
 *
 * Construct translation table for translate().
 * BUGS: only works with ASCII
 */

string maketrans(in char[] from, in char[] to)
...
}

/******************************************
 * $(RED Scheduled for deprecation in March 2012.
 *   Please use the version of $(D translate) which takes an AA instead.)
 *
 * Translate characters in s[] using table created by maketrans().
 * Delete chars in delchars[].
 * BUGS: only works with ASCII
 */

string translate()(in char[] s, in char[] transtab, in char[] delchars)

--------------------

My suggestions are:

1) To remove from both ddocs the "$(RED Scheduled for deprecation in March 2012.)" and replace "BUGS: only works with ASCII" with something like: "NOTE: only works with ASCII."


2) This is the signature of the ascii version of translate:

string translate()(in char[] s, in char[] transtab, in char[] delchars)

I suggest to add a null default argument for the "delchars" argument:

string translate()(in char[] s, in char[] transtab, in char[] delchars=null)

This makes translate() more handy, and it's more similar to the Python
str.translate() method this D function is *copied* from:


>>> from string import maketrans
>>> t = maketrans("abc", "XYZ")
>>> "absent".translate(t, "tn")
'XYse'
>>> "absent".translate(t)
'XYsent'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8141


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-05-28 17:17:53 PDT ---
https://github.com/D-Programming-Language/phobos/pull/609

does this as part of fixing issue# 7515.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8141


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED


--- Comment #2 from yebblies <yebblies@gmail.com> 2012-12-26 23:48:16 EST ---
I'm guessing this was fixed sufficiently by https://github.com/D-Programming-Language/phobos/commit/94c06fb2469c0d98be842438b749e61571b42fe3

Please reopen if that's not the case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------