Replace core language HexStrings with library entity
Baz via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 17 08:45:41 PDT 2015
On Monday, 16 March 2015 at 21:32:45 UTC, Baz wrote:
> On Monday, 16 March 2015 at 16:45:25 UTC, Andrei Alexandrescu
>> On 3/16/15 9:29 AM, Baz wrote:
>>> On Sunday, 15 March 2015 at 21:41:06 UTC, bearophile wrote:
>>>> Walter Bright:
>>>>> Unfortunately, it needs to be a dropin replacement for
>>>>> x"...", which
>>>>> returns a string/wstring/dstring.
>>>> This is bad. 99% of the times you don't want a
>>>> out of a hex string:
>>> this is the API that's about to be proposed, it named as
>>> suggested by
>>> A.A., and it handles the two issues you point out:
>>> public string hexString(string hexData, bool putWhites =
>>> public string hexString(dstring hexData, bool putWhites =
>>> public string hexString(wstring hexData, bool putWhites =
>>> public ubyte hexBytes(string hexData)()
>>> public ubyte hexBytes(dstring hexData)()
>>> public ubyte hexBytes(wstring hexData)()
>> (Drop the "public", this ain't Java.)
>> I don't see a necessity for the input string having different
>> widths; string is enough. There may be a necessity to choose
>> the width of the output with changes in function name, e.g.
>> hexWString and hexDString.
>> That opens the question whether we want only ubyte for hex
>> bytes or all integral types.
>>> additionally to x string, a template parameter allows to put
>>> raw whites,
>>> assert(hexString!("30 30", true) == "0 1");
>>> assert(hexString!("30 31") == "01"); // standard x string
>> I don't see a need for this.
> I'd like to propose this:
> But after reading D.Nadlinger mind about the whole thing i
> realize that's the opposite the things should be done in the
> opposite way.
Despite of the personnal opinion over the idea of removing x
strings from the lang and integrate them as a phobos template is
there any particulur "no no no" that would automatically prevent
this to be an acceptable PR (style, guidline, foreach vs range
Sorry to insist but this is the first time i try to propose
something and i'm usually less strict with my own things.
Thx to reply, otherwise i give it up.
More information about the Digitalmars-d