Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 15, 2015 Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
HexStrings: http://dlang.org/lex.html#HexString They're rarely used, but very useful when needed. But, as the octal literals have shown, they can be easily replaced with a library template: x"00 FBCD 32FD 0A" becomes: hex!"00 FBCD 32FD 0A" It'll simplify the core language slightly. Thoughts? Anyone want to write the hex template? Any other ideas on things that can removed from the core language and replaced with library entities? |
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | The motivation for this came from a post by deadalnix. |
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | http://dpaste.dzfl.pl/0f63623cc262a ? |
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sunday, 15 March 2015 at 19:48:22 UTC, Walter Bright wrote:
> The motivation for this came from a post by deadalnix.
And I'm obviously all for it :)
|
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Sunday, 15 March 2015 at 19:55:39 UTC, Kagamin wrote:
> http://dpaste.dzfl.pl/0f63623cc262a ?
Wrong link? Or wrong thread?
|
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sunday, 15 March 2015 at 19:47:06 UTC, Walter Bright wrote:
> HexStrings:
>
> http://dlang.org/lex.html#HexString
>
> They're rarely used, but very useful when needed. But, as the octal literals have shown, they can be easily replaced with a library template:
>
> x"00 FBCD 32FD 0A"
>
> becomes:
>
> hex!"00 FBCD 32FD 0A"
>
> It'll simplify the core language slightly.
>
> Thoughts? Anyone want to write the hex template? Any other ideas on things that can removed from the core language and replaced with library entities?
Can we make it so it returns a ubyte[]?
|
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sunday, 15 March 2015 at 19:47:06 UTC, Walter Bright wrote: > HexStrings: > > http://dlang.org/lex.html#HexString > > They're rarely used, but very useful when needed. But, as the octal literals have shown, they can be easily replaced with a library template: > > x"00 FBCD 32FD 0A" > > becomes: > > hex!"00 FBCD 32FD 0A" > > Thoughts? Anyone want to write the hex template? I'd be interested. Here's a quick draft based on octal: http://dpaste.dzfl.pl/656a94cdfdba |
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | Marc Schütz:
> Can we make it so it returns a ubyte[]?
There is an enhancement request on this (for the built in hex strings).
Bye,
bearophile
|
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Baz | On 3/15/2015 2:18 PM, Baz wrote:
> On Sunday, 15 March 2015 at 19:47:06 UTC, Walter Bright wrote:
>> HexStrings:
>>
>> http://dlang.org/lex.html#HexString
>>
>> They're rarely used, but very useful when needed. But, as the octal literals
>> have shown, they can be easily replaced with a library template:
>>
>> x"00 FBCD 32FD 0A"
>>
>> becomes:
>>
>> hex!"00 FBCD 32FD 0A"
>>
>> Thoughts? Anyone want to write the hex template?
>
> I'd be interested. Here's a quick draft based on octal:
>
> http://dpaste.dzfl.pl/656a94cdfdba
>
I think you've got the right idea. Time for a pull request?
P.S. Also need to include all the examples in the dlang reference as unittest cases.
|
March 15, 2015 Re: Replace core language HexStrings with library entity | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | On 3/15/2015 1:38 PM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm@gmx.net>" wrote:
> Can we make it so it returns a ubyte[]?
Unfortunately, it needs to be a dropin replacement for x"...", which returns a string/wstring/dstring.
|
Copyright © 1999-2021 by the D Language Foundation