Replace core language HexStrings with library entity

H. S. Teoh via Digitalmars-d digitalmars-d at
Sun Mar 15 16:10:58 PDT 2015

On Sun, Mar 15, 2015 at 11:32:04PM +0100, FG via Digitalmars-d wrote:
> On 2015-03-15 at 22:41, 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 string/wstring/dstring
> >out of a hex string:
> Then maybe hex!"..." should produce the desired ubyte[] and something
> with a different name (for example hexString!"...") would be the
> drop-in replacement for x"...", returning a string. The more complex
> name being a hint that what you really need is hex.

+1. I like this.

I was quite disappointed when I first learned that x"..." returns a
string rather than immutable(ubyte)[]. I have quite a number of use
cases in mind where I'd want to specify hex values to represent binary
data, but can't think of any where I'd want to do that to represent
string data. Needing to use casts with x"..." just looks wrong.

So using hex!"..." for immutable(ubyte)[] gets +1 from me.  Leave
hexString!"..." to emulate the current behaviour of x"...".


War doesn't prove who's right, just who's left. -- BSD Games' Fortune

More information about the Digitalmars-d mailing list