4-character literal

Rick Mann rmann-d-lang at latencyzero.com
Fri Jan 26 12:38:03 PST 2007


Joel C. Salomon Wrote:

> Rick Mann wrote:
> > Sadly, nothing's really as nice as just saying 'abcd'. What would it take to get multi-character literals added to the language?
> 
> In the process of learning to scan C (for a compiler theory class), I 
> first heard about those.  Seems not-too-useful.  If you want a number, 
> input the number; if you want a Unicode character, enter L'é‚£' (or 
> whatever the D equivalent is).  Entering numbers in base 256 is asking 
> for trouble, especially with UTF-8 source.

I gotta say, I think they're very useful. Multibyte-character issues aside, it can be a lot handier to see 'abcd' in a debugger than '61626364'. And handling multibyte characters isn't that big a deal...just include all the bytes. If the integer interpretation is 4 bytes, treat it as an uint. If it's more, treat it as a ulong, and issue appropriate warnings/errors when assigning. Pad the values out with zeros. I'm not sure I understand the resistance to the notion.




More information about the Digitalmars-d mailing list