Jump to page: 1 2
Thread overview
hex strings
Jan 26, 2011
Ellery Newcomer
Jan 26, 2011
Jonathan M Davis
Jan 26, 2011
bearophile
Jan 26, 2011
Jonathan M Davis
Jan 26, 2011
Ellery Newcomer
Jan 26, 2011
Jonathan M Davis
Jan 26, 2011
Simen kjaeraas
Jan 26, 2011
Ellery Newcomer
Jan 26, 2011
bearophile
Jan 26, 2011
spir
Jan 27, 2011
Simen kjaeraas
Jan 27, 2011
Ellery Newcomer
January 26, 2011
just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing

cast(ubyte[]) x"..."
January 26, 2011
On Wednesday, January 26, 2011 10:25:29 Ellery Newcomer wrote:
> just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing
> 
> cast(ubyte[]) x"..."

That's legal? I thought that x went in front of hex literals, not strings. I wouldn't have thought that that code would compile, and I certainly have no clue what you're trying to do. So, I certainly don't fall in the category of anyone using it - regardless of whether it's meant to be a string or not.

- Jonathan M Davis
January 26, 2011
Jonathan M Davis:

> That's legal?

They are a part of D language, search for "Hex Strings" here: http://www.digitalmars.com/d/2.0/lex.html

Bye,
bearophile
January 26, 2011
On Wednesday, January 26, 2011 11:29:59 bearophile wrote:
> Jonathan M Davis:
> > That's legal?
> 
> They are a part of D language, search for "Hex Strings" here: http://www.digitalmars.com/d/2.0/lex.html

It always seems like there's at least one more thing in the language that I have no idea is there...

- Jonathan M Davis
January 26, 2011
On 01/26/2011 01:35 PM, Jonathan M Davis wrote:
> On Wednesday, January 26, 2011 11:29:59 bearophile wrote:
>> Jonathan M Davis:
>>> That's legal?
>>
>> They are a part of D language, search for "Hex Strings" here:
>> http://www.digitalmars.com/d/2.0/lex.html
>
> It always seems like there's at least one more thing in the language that I have
> no idea is there...
>
> - Jonathan M Davis

helps to have written a D lexer or two. weren't you going to do that?
January 26, 2011
Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote:

> just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing
>
> cast(ubyte[]) x"..."

Never used them, tbh. But shouldn't that be

cast(ubyte[]) x"...".dup

?

-- 
Simen
January 26, 2011
On 01/26/2011 02:16 PM, Simen kjaeraas wrote:
> Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote:
>
>> just out of curiosity, does anyone use these and actually mean them to
>> be strings? It seems like I'm invariably writing
>>
>> cast(ubyte[]) x"..."
>
> Never used them, tbh. But shouldn't that be
>
> cast(ubyte[]) x"...".dup
>
> ?
>

yeah, strictly speaking. but that (or cast(immutable(ubyte[]))) would be even uglier.
January 26, 2011
Simen kjaeraas:

> > cast(ubyte[]) x"..."
> 
> Never used them, tbh. But shouldn't that be
> 
> cast(ubyte[]) x"...".dup

Maybe it's to avoid such mistakes that C++ has const_cast separated from other casts.

Bye,
bearophile
January 26, 2011
On Wednesday 26 January 2011 11:53:32 Ellery Newcomer wrote:
> On 01/26/2011 01:35 PM, Jonathan M Davis wrote:
> > On Wednesday, January 26, 2011 11:29:59 bearophile wrote:
> >> Jonathan M Davis:
> >>> That's legal?
> >> 
> >> They are a part of D language, search for "Hex Strings" here: http://www.digitalmars.com/d/2.0/lex.html
> > 
> > It always seems like there's at least one more thing in the language that I have no idea is there...
> > 
> > - Jonathan M Davis
> 
> helps to have written a D lexer or two. weren't you going to do that?

I've been working on it off and on, but I've been busy enough that I haven't made as much progress on it as I'd like. Even so though, I might have already run into it there and totally forgot about it, because it's a feature that I've never used and have no use for.

- Jonathan M Davis
January 26, 2011
On 01/26/2011 07:25 PM, Ellery Newcomer wrote:
> just out of curiosity, does anyone use these and actually mean them to be
> strings? It seems like I'm invariably writing
>
> cast(ubyte[]) x"..."

Super-nice for universal text. Anything you can't type in because of non-illimited keyboard size...

Actually had a similar idea, except using in-string delimiters #...# instead of a prefix:
	"#xx xxx xxxx xxx#"
Adds one char compared to D syntax, but allows partially hex-coded string:
	"blah #xx xxxx xxx# blah"

Denis
-- 
_________________
vita es estrany
spir.wikidot.com

« First   ‹ Prev
1 2