Regarding hex strings

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Sat Oct 20 13:37:06 PDT 2012


On Fri, 19 Oct 2012 20:46:06 +0200
> 
> For general purpose binary data (i.e. _not_ UTF encoded Unicode 
> text) I also _already_ said IMO should be either stored as 
> ubyte[]

Problem is, x"..." is FAR better syntax for that.

> or better yet their own types that would ensure the 
> correct invariants for the data type, be it audio, video, or just 
> a different text encoding.

Using x"..." doesn't prevent anyone from doing that:

auto a = SomeAudioType(x"...");

> 
> In neither case the hex-string is relevant IMO. In the former it 
> potentially violates the type's invariant and in the latter we 
> already have array literals.
> 
> Using a malformed _string_ to initialize ubyte[] IMO is simply 
> less readable. How did that article call such features, "WAT"?

The only thing ridiculous about x"..." is that somewhere along the
lines it was decided that it must be a string instead of the arbitrary
binary data that it *is*.



More information about the Digitalmars-d mailing list