Re: missing HexString documentation

2018-02-13 Thread Steven Schveighoffer via Digitalmars-d
On 2/11/18 4:48 PM, Walter Bright wrote: I also notice that hex strings are not simply equivalent to strings with \x in them -- the latter is more constrained, as it must be a pair of hex digits per \x. hex strings allow spaces between them. The idea was to be able to cut text from things

Re: missing HexString documentation

2018-02-11 Thread Walter Bright via Digitalmars-d
On 2/11/2018 6:09 AM, Steven Schveighoffer wrote: On 2/8/18 3:49 PM, Walter Bright wrote: That would be a language change proposal or bug report. By all means, please do so. https://issues.dlang.org/show_bug.cgi?id=18420 Good! I also notice that hex strings are not simply equivalent to

Re: missing HexString documentation

2018-02-11 Thread Steven Schveighoffer via Digitalmars-d
On 2/8/18 3:49 PM, Walter Bright wrote: On 2/8/2018 10:42 AM, Steven Schveighoffer wrote: On 2/8/18 1:25 PM, Walter Bright wrote: "abc" is an array (it's an immutable(char)[]). There's no reason why ['a','b','c'] should be different than "abc" (other than the hidden null character, which is

Re: missing HexString documentation

2018-02-08 Thread Walter Bright via Digitalmars-d
On 2/8/2018 10:42 AM, Steven Schveighoffer wrote: On 2/8/18 1:25 PM, Walter Bright wrote: "abc" is an array (it's an immutable(char)[]). There's no reason why ['a','b','c'] should be different than "abc" (other than the hidden null character, which is irrelevant here). ['a','b','c'] is

Re: missing HexString documentation

2018-02-08 Thread Walter Bright via Digitalmars-d
On 2/8/2018 10:49 AM, Steven Schveighoffer wrote: On 2/8/18 1:42 PM, Ralph Doncaster wrote: On Thursday, 8 February 2018 at 18:31:06 UTC, Walter Bright wrote: db    0ffdeh,0ffadh,0ffbeh,0ffefh    ; But it looks like they are all dchar, so 4x the space vs x"deadbeef"?

Re: missing HexString documentation

2018-02-08 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 18:49:51 UTC, Steven Schveighoffer wrote: I wonder if it's an issue with how obj2asm prints it out? Surely, that data array must be contiguous, and they must be bytes. Otherwise the resulting code would be wrong. OK. I didn't even know about obj2asm until you

Re: missing HexString documentation

2018-02-08 Thread Steven Schveighoffer via Digitalmars-d
On 2/8/18 1:42 PM, Ralph Doncaster wrote: On Thursday, 8 February 2018 at 18:31:06 UTC, Walter Bright wrote: On 2/8/2018 5:26 AM, Steven Schveighoffer wrote: The extra data in the object file comes from the inclusion of the hexStringImpl function, and from the template parameter (the symbol

Re: missing HexString documentation

2018-02-08 Thread Steven Schveighoffer via Digitalmars-d
On 2/8/18 1:25 PM, Walter Bright wrote: On 2/8/2018 7:07 AM, Steven Schveighoffer wrote: My concern in the hexString case is the sheer requirement of CTFE for something that is so easy to do in the compiler, already *done* in the compiler, and has another form specifically for hex strings (the

Re: missing HexString documentation

2018-02-08 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 18:31:06 UTC, Walter Bright wrote: On 2/8/2018 5:26 AM, Steven Schveighoffer wrote: The extra data in the object file comes from the inclusion of the hexStringImpl function, and from the template parameter (the symbol

Re: missing HexString documentation

2018-02-08 Thread Walter Bright via Digitalmars-d
On 2/8/2018 5:26 AM, Steven Schveighoffer wrote: The extra data in the object file comes from the inclusion of the hexStringImpl function, and from the template parameter (the symbol _D3std4conv__T9hexStringVAyaa8_6465616462656566ZQBiyAa is in there as well, which will always be larger than

Re: missing HexString documentation

2018-02-08 Thread Walter Bright via Digitalmars-d
On 2/8/2018 7:07 AM, Steven Schveighoffer wrote: My concern in the hexString case is the sheer requirement of CTFE for something that is so easy to do in the compiler, already *done* in the compiler, and has another form specifically for hex strings (the "\xde\xad\xbe\xef" form) that isn't

Re: missing HexString documentation

2018-02-08 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 17:06:55 UTC, H. S. Teoh wrote: On Thu, Feb 08, 2018 at 08:26:03AM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] The extra data in the object file comes from the inclusion of the hexStringImpl function, and from the template parameter (the symbol

Re: missing HexString documentation

2018-02-08 Thread H. S. Teoh via Digitalmars-d
On Thu, Feb 08, 2018 at 08:26:03AM -0500, Steven Schveighoffer via Digitalmars-d wrote: [...] > The extra data in the object file comes from the inclusion of the > hexStringImpl function, and from the template parameter (the symbol > _D3std4conv__T9hexStringVAyaa8_6465616462656566ZQBiyAa is in

Re: missing HexString documentation

2018-02-08 Thread Steven Schveighoffer via Digitalmars-d
On 2/8/18 9:44 AM, Adam D. Ruppe wrote: On Thursday, 8 February 2018 at 13:06:44 UTC, Steven Schveighoffer wrote: So you think it should go into druntime? I don't see why it wasn't in there in the first place to be honest. Yeah, probably. I might even publically import it when you import the

Re: missing HexString documentation

2018-02-08 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 8 February 2018 at 13:06:44 UTC, Steven Schveighoffer wrote: So you think it should go into druntime? I don't see why it wasn't in there in the first place to be honest. Yeah, probably. I might even publically import it when you import the posix header so it just works in the

Re: missing HexString documentation

2018-02-08 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 8 February 2018 at 10:52:35 UTC, Kagamin wrote: Or have a function specifically for unix permissions, like int unix(int r, int w, int x, int gr, int gw, int gx, int ur, int uw, int ux); It might be even more readable. I actually personally prefer binary: 0b_1_111_101_000 which

Re: missing HexString documentation

2018-02-08 Thread Steven Schveighoffer via Digitalmars-d
On 2/8/18 1:10 AM, Walter Bright wrote: On 2/7/2018 9:45 PM, Ralph Doncaster wrote: > While the fix is a huge improvement, it doesn't match the code generated by the hex literals.  hexString!"deadbeef" stores the null-terminated string in the data section of the object file, while

Re: missing HexString documentation

2018-02-08 Thread Steven Schveighoffer via Digitalmars-d
On 2/7/18 3:24 PM, Adam D. Ruppe wrote: On Wednesday, 7 February 2018 at 18:59:38 UTC, Steven Schveighoffer wrote: Not even close. Octal literals are a disaster, because putting a leading 0 should never change the base of a number. I agree the leading 0 is terrible. But that's not the real

Re: missing HexString documentation

2018-02-08 Thread Kagamin via Digitalmars-d
Or have a function specifically for unix permissions, like int unix(int r, int w, int x, int gr, int gw, int gx, int ur, int uw, int ux); It might be even more readable.

Re: missing HexString documentation

2018-02-08 Thread Kagamin via Digitalmars-d
On Wednesday, 7 February 2018 at 17:01:54 UTC, Adam D. Ruppe wrote: http://dpldocs.info/experimental-docs/source/core.sys.posix.fcntl.d.html#L123 version (X86) { enum O_CREAT= 0x40; // octal 0100 enum O_EXCL = 0x80; // octal 0200

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 9:45 PM, Ralph Doncaster wrote: > While the fix is a huge improvement, it doesn't match the code generated by the hex literals. hexString!"deadbeef" stores the null-terminated string in the data section of the object file, while x"deadbeef" only stores 4 bytes in the data section.

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 01:53:43 UTC, Walter Bright wrote: On 2/7/2018 11:29 AM, Ralph Doncaster wrote: I just did a quick check, and with DMD v2.078.1, the hexString template increases code size by ~300 bytes vs the hex literal. So yet one more reason to prefer the hex literals.

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 01:27:46 UTC, Seb wrote: On Thursday, 8 February 2018 at 00:55:28 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:41:37 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: [...] They are deprecated:

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Thursday, 8 February 2018 at 00:24:22 UTC, Walter Bright wrote: On 2/7/2018 8:03 AM, Ralph Doncaster wrote: As expected, auto data = cast(ubyte[]) x"deadbeef"; works with -betterC, but auto data = cast(ubyte[]) hexString!"deadbeef"; does not. When I tried it: import std.conv; void

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 6:39 PM, Adam D. Ruppe wrote: On Thursday, 8 February 2018 at 01:55:19 UTC, Walter Bright wrote: No, because their usage by druntime is nearly nonexistent. Only because they're not supported! Code like `0xsomething // octal something else` is found a whopping 200 times in

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 6:39 PM, H. S. Teoh wrote: and hope to make a PR forit shortly. https://issues.dlang.org/show_bug.cgi?id=18397 The bug report didn't explain what exactly in the implementation wasn't done right. :-/ The PR does. https://github.com/dlang/phobos/pull/6138 Another data

Re: missing HexString documentation

2018-02-07 Thread H. S. Teoh via Digitalmars-d
On Wed, Feb 07, 2018 at 05:53:43PM -0800, Walter Bright via Digitalmars-d wrote: > On 2/7/2018 11:29 AM, Ralph Doncaster wrote: > > I just did a quick check, and with DMD v2.078.1, the hexString > > template increases code size by ~300 bytes vs the hex literal. So > > yet one more reason to prefer

Re: missing HexString documentation

2018-02-07 Thread H. S. Teoh via Digitalmars-d
On Thu, Feb 08, 2018 at 02:39:50AM +, Adam D. Ruppe via Digitalmars-d wrote: > On Thursday, 8 February 2018 at 01:55:19 UTC, Walter Bright wrote: > > No, because their usage by druntime is nearly nonexistent. > > Only because they're not supported! > > Code like `0xsomething // octal

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 8 February 2018 at 01:55:19 UTC, Walter Bright wrote: No, because their usage by druntime is nearly nonexistent. Only because they're not supported! Code like `0xsomething // octal something else` is found a whopping 200 times in druntime (granted btw all in the core.sys

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 4:25 PM, H. S. Teoh wrote: Should templates like octal and hexString be in druntime instead? No, because their usage by druntime is nearly nonexistent.

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 5:03 PM, Seb wrote: On Thursday, 8 February 2018 at 00:24:22 UTC, Walter Bright wrote: On 2/7/2018 8:03 AM, Ralph Doncaster wrote: As expected, auto data = cast(ubyte[]) x"deadbeef"; works with -betterC, but auto data = cast(ubyte[]) hexString!"deadbeef"; does not. When I tried

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 11:29 AM, Ralph Doncaster wrote: I just did a quick check, and with DMD v2.078.1, the hexString template increases code size by ~300 bytes vs the hex literal. So yet one more reason to prefer the hex literals. Indeed it does, and that is the result of a poor implementation of

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 8 February 2018 at 00:24:22 UTC, Walter Bright wrote: dmd -c -betterC test2.d Don't use -c with -betterC when doing tests. The majority of troubles we have are likely to be linker errors (undefined references to missing runtime) and that silences them.

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Thursday, 8 February 2018 at 00:55:28 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:41:37 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: [...] They are deprecated: https://dlang.org/changelog/pending.html#hexstrings

Re: missing HexString documentation

2018-02-07 Thread Mike Franklin via Digitalmars-d
On Thursday, 8 February 2018 at 00:25:21 UTC, H. S. Teoh wrote: hexString is in Phobos, and druntime can't use Phobos. Should templates like octal and hexString be in druntime instead? IMO, no. I think the interdependencies between the compiler, druntime, phobos, and even the packages

Re: missing HexString documentation

2018-02-07 Thread Mike Franklin via Digitalmars-d
On Wednesday, 7 February 2018 at 16:03:36 UTC, Steven Schveighoffer wrote: They are deprecated: https://dlang.org/changelog/pending.html#hexstrings https://dlang.org/deprecate.html#Hexstring%20literals Wow, that's... a little superfluous. I agree with the notion that the language should be

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Thursday, 8 February 2018 at 00:24:22 UTC, Walter Bright wrote: On 2/7/2018 8:03 AM, Ralph Doncaster wrote: As expected, auto data = cast(ubyte[]) x"deadbeef"; works with -betterC, but auto data = cast(ubyte[]) hexString!"deadbeef"; does not. When I tried it: import std.conv; void

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Wednesday, 7 February 2018 at 15:41:37 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: On 2/7/18 9:59 AM, Ralph Doncaster wrote: [...] Good catch! Even the grammar says nothing about what it is, except it has HexString as a possible literal.

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 4:08 PM, Mike Franklin wrote: Don't search for "[betterC]".  Instead, use "betterC" (without the brackets). https://issues.dlang.org/buglist.cgi?quicksearch=betterc_id=219390 We can't reliably rely on informal conventions. I used the wrong URL. This is the right one (a keyword

Re: missing HexString documentation

2018-02-07 Thread H. S. Teoh via Digitalmars-d
On Wed, Feb 07, 2018 at 04:11:19PM -0800, Walter Bright via Digitalmars-d wrote: > On 2/7/2018 12:13 PM, Adam D. Ruppe wrote: > > even that minor hassle has hurt the use in practice, like in the > > druntime examples. > > hexString is in Phobos, and druntime can't use Phobos. Should templates

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 8:03 AM, Ralph Doncaster wrote: As expected, auto data = cast(ubyte[]) x"deadbeef"; works with -betterC, but auto data = cast(ubyte[]) hexString!"deadbeef"; does not. When I tried it: import std.conv; void test() { auto data = cast(ubyte[]) hexString!"deadbeef"; }

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 12:13 PM, Adam D. Ruppe wrote: even that minor hassle has hurt the use in practice, like in the druntime examples. hexString is in Phobos, and druntime can't use Phobos.

Re: missing HexString documentation

2018-02-07 Thread Mike Franklin via Digitalmars-d
On Wednesday, 7 February 2018 at 23:30:57 UTC, Walter Bright wrote: Can you please provide a list of these issues, and file issues that aren't on bugzilla yet, and tag them with the betterC keyword? I see only one: https://issues.dlang.org/buglist.cgi?quicksearch=%5Bbetterc%5D_id=219382

Re: missing HexString documentation

2018-02-07 Thread Walter Bright via Digitalmars-d
On 2/7/2018 8:05 AM, Adam D. Ruppe wrote: That's just because -betterC is buggy and extremely incomplete Can you please provide a list of these issues, and file issues that aren't on bugzilla yet, and tag them with the betterC keyword? I see only one:

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 7 February 2018 at 18:59:38 UTC, Steven Schveighoffer wrote: Not even close. Octal literals are a disaster, because putting a leading 0 should never change the base of a number. I agree the leading 0 is terrible. But that's not the real question here: it is 0o100 vs import

Re: missing HexString documentation

2018-02-07 Thread H. S. Teoh via Digitalmars-d
On Wed, Feb 07, 2018 at 07:29:10PM +, Ralph Doncaster via Digitalmars-d wrote: [...] > I just did a quick check, and with DMD v2.078.1, the hexString > template increases code size by ~300 bytes vs the hex literal. So yet > one more reason to prefer the hex literals. Arguably, this is a QoI

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 7 February 2018 at 19:38:35 UTC, Ali Çehreli wrote: It sounds so natural. I forgot; what was the argument against it? 0o was denied basically just because we felt it wasn't necessary to have in the language at all; that it was rare enough and the library *can* do it, so the

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 7 February 2018 at 17:36:56 UTC, Seb wrote: Octal predates GitHub, hexString is new: Yes, I know, I was there :) Heck, in the hexString forum thread, I argued that people knowing this pattern is really useful because then they can do all kinds of custom literals like stripping

Re: missing HexString documentation

2018-02-07 Thread Ali Çehreli via Digitalmars-d
On 02/07/2018 09:01 AM, Adam D. Ruppe wrote: > But for octal? It was a mistake. We should have just made it 0o. It sounds so natural. I forgot; what was the argument against it? Ali

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Wednesday, 7 February 2018 at 16:51:02 UTC, Seb wrote: On Wednesday, 7 February 2018 at 16:03:36 UTC, Steven Schveighoffer wrote: Seems like the same code you would need to parse the first is reusable for the second, no? I don't see why this deprecation was necessary, and now we have more

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Wednesday, 7 February 2018 at 19:25:37 UTC, Ralph Doncaster wrote: On Wednesday, 7 February 2018 at 16:51:02 UTC, Seb wrote: On Wednesday, 7 February 2018 at 16:03:36 UTC, Steven Schveighoffer wrote: Seems like the same code you would need to parse the first is reusable for the second, no?

Re: missing HexString documentation

2018-02-07 Thread Steven Schveighoffer via Digitalmars-d
On 2/7/18 12:01 PM, Adam D. Ruppe wrote: On Wednesday, 7 February 2018 at 16:51:02 UTC, Seb wrote: For the same reason why octal literals have been deprecated years ago: https://dlang.org/deprecate.html#Octal%20literals Not even close. Octal literals are a disaster, because putting a leading

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Wednesday, 7 February 2018 at 17:01:54 UTC, Adam D. Ruppe wrote: The octal library solution is brilliant. The genius who wrote that code is clearly god-like and we should all fall to our knees and worship his superior intellect. That pattern DOES have uses. Octal predates GitHub,

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 7 February 2018 at 16:51:02 UTC, Seb wrote: For the same reason why octal literals have been deprecated years ago: https://dlang.org/deprecate.html#Octal%20literals The library solution works as well and it's one of the features that are rarely used and add up to the steep

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Wednesday, 7 February 2018 at 16:03:36 UTC, Steven Schveighoffer wrote: On 2/7/18 10:41 AM, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: On 2/7/18 9:59 AM, Ralph Doncaster wrote: It is mentioned in the literals section, but not documented:

Re: missing HexString documentation

2018-02-07 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 7 February 2018 at 16:03:17 UTC, Ralph Doncaster wrote: As expected, auto data = cast(ubyte[]) x"deadbeef"; works with -betterC, but auto data = cast(ubyte[]) hexString!"deadbeef"; does not. That's just because -betterC is buggy and extremely incomplete (this is why I'm so

Re: missing HexString documentation

2018-02-07 Thread Steven Schveighoffer via Digitalmars-d
On 2/7/18 10:41 AM, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: On 2/7/18 9:59 AM, Ralph Doncaster wrote: It is mentioned in the literals section, but not documented: https://dlang.org/spec/lex.html#string_literals  From reading forum posts I managed

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Wednesday, 7 February 2018 at 15:54:05 UTC, Ralph Doncaster wrote: Doesn't that go against the idea of -betterC, or will std.conv work with -betterC. p.s. contrary to what the deprecation notice says, hex strings are very often used in crypto/hashing test cases. Most hash specs have

Re: missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
On Wednesday, 7 February 2018 at 15:41:37 UTC, Seb wrote: On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: On 2/7/18 9:59 AM, Ralph Doncaster wrote: It is mentioned in the literals section, but not documented: https://dlang.org/spec/lex.html#string_literals From

Re: missing HexString documentation

2018-02-07 Thread Seb via Digitalmars-d
On Wednesday, 7 February 2018 at 15:25:05 UTC, Steven Schveighoffer wrote: On 2/7/18 9:59 AM, Ralph Doncaster wrote: It is mentioned in the literals section, but not documented: https://dlang.org/spec/lex.html#string_literals From reading forum posts I managed to figure out that HexStrings

Re: missing HexString documentation

2018-02-07 Thread Steven Schveighoffer via Digitalmars-d
On 2/7/18 9:59 AM, Ralph Doncaster wrote: It is mentioned in the literals section, but not documented: https://dlang.org/spec/lex.html#string_literals From reading forum posts I managed to figure out that HexStrings are prefixed with an x.  i.e. x"deadbeef" Good catch! Even the grammar

missing HexString documentation

2018-02-07 Thread Ralph Doncaster via Digitalmars-d
It is mentioned in the literals section, but not documented: https://dlang.org/spec/lex.html#string_literals From reading forum posts I managed to figure out that HexStrings are prefixed with an x. i.e. x"deadbeef"