February 07, 2018
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.
February 07, 2018
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";
  }

with:

  dmd -c -betterC test2.d

it compiled without complaint. Are you doing something different? (This is why posting complete examples, not snippets, is better. That way I don't have to fill in the blanks with guesswork.)
February 07, 2018
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 like octal and hexString be in druntime instead?


T

-- 
There are 10 kinds of people in the world: those who can count in binary, and those who can't.
February 07, 2018
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&list_id=219390
> 
> We can't reliably rely on informal conventions.

I used the wrong URL. This is the right one (a keyword search, not a text search):

https://issues.dlang.org/buglist.cgi?keywords=betterC&list_id=219394&resolution=---

which lists 13 issues. Two of them were missing, and I annotated them with the keyword betterC, so it's 15.
February 08, 2018
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.
>>
>> Can you file an issue? https://issues.dlang.org
>>
>> -Steve
>
> They are deprecated:
>
> https://dlang.org/changelog/pending.html#hexstrings
> https://dlang.org/deprecate.html#Hexstring%20literals
>
> Hence, the grammar has been incompletely updated. As it's not an error to use them now, it should have stated that they are deprecated.
>
> Anyhow, you can always go back in time:
>
> https://docarchives.dlang.io/v2.078.0/spec/lex.html#HexString

PR: https://github.com/dlang/dlang.org/pull/2190
February 08, 2018
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 test() {
>     auto data = cast(ubyte[]) hexString!"deadbeef";
>   }
>
> with:
>
>   dmd -c -betterC test2.d
>
> it compiled without complaint. Are you doing something different? (This is why posting complete examples, not snippets, is better. That way I don't have to fill in the blanks with guesswork.)

https://run.dlang.io/is/TEJDZO and hit "Run".

I also opened a Bugzilla issue, s.t. it doesn't get lost https://issues.dlang.org/show_bug.cgi?id=18395
February 08, 2018
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 an aggregate of primitives, and anything that can be composed of those primitives should be implemented in a library (unless a compelling reason is found to justify otherwise).  The deprecation of hex string literals has exposed flaws in the library implementation and the compiler's template implementation.  That doesn't mean deprecation was the wrong thing to do; it just brings the aforementioned flaws to the forefront, so let's not shoot the messenger.

Here's a few fundamental flaws I see in our library implementations.
* Some library implementations are not very cohesive, and have too many interdependencies.  This is what seems to prevent `HexString` from being used in -betterC.
* Some Phobos implementations would be quite useful in Druntime and in code that doesn't want to employ the runtime (e.g. libraries consumed by other languages, resource-constrained systems, and bare-metal programming), but alas, Druntime can't have a circular dependency on Phobos (nor should it).

This is a difficult problem, and I don't have any solutions; just ideas.  Maybe Phobos and Druntime should be divided into 3 libraries:

1.  A library with no dependencies whatsoever, not even druntime, c runtime, or the C standard library.  Some stuff in `std.traits`, `std.conv`, and even `HexString` could go here.  Let's call this library DLib.
2.  Druntime would only depend on DLib, but never publicly expose it.
3.  Phobos could depend on DLib or Druntime, but again, never publicly expose it.
4.  Phobos could be refactored by identifying packages that have too much coupling, and factoring out the dependencies into a 3rd, more cohesive library, imported by the previous two.

For extra credit:
2a. Move C/C++ standard library bindings to Deimos, and have the desktop OS ports import it privately.  There's no reason to impose this interface on bare-metal ports, and it's a superficial dependency anyway.
3a. Phobos shouldn't have any dependency on C/C++ language bindings.  DRuntime should expose an idiomatic D (and preferably @safe) interface for Phobos to use.

DLib could then be used in -betterC and other use cases where Druntime is more of a liability than an asset.

Mike


February 08, 2018
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 contained within needs some remodeling.  I posted some of my initial thoughts here:  https://forum.dlang.org/post/wvmgimzlwuwywxhhyhpi@forum.dlang.org

Mike


February 08, 2018
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.
February 08, 2018
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
>> https://dlang.org/deprecate.html#Hexstring%20literals
>>
>> Hence, the grammar has been incompletely updated. As it's not an error to use them now, it should have stated that they are deprecated.
>>
>> Anyhow, you can always go back in time:
>>
>> https://docarchives.dlang.io/v2.078.0/spec/lex.html#HexString
>
> PR: https://github.com/dlang/dlang.org/pull/2190

... and back online: http://dlang.org/spec/lex.html#hex_strings