Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Seb via Digitalmars-d-announce

On Thursday, 16 May 2019 at 05:14:39 UTC, Nicholas Wilson wrote:

[...]


Yes that sounds like the culprit. Btw as mentioned on DConf, the 
dip1000 switch contains a few other breaking changes which will 
make it even harder to adopt too.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Nicholas Wilson via Digitalmars-d-announce

On Thursday, 16 May 2019 at 01:05:53 UTC, H. S. Teoh wrote:
Gah, so apparently .hashOf is a gigantic overload set of *21* 
different overloads, so this is not really "truly" reduced. =-O


Anybody up for figuring out which overload(s) is/are getting 
called?


https://github.com/dlang/druntime/blob/master/src/core/internal/hash.d#L393

static if (hasCallableToHash!(typeof(val))){ ... } // false
else
{
static if (__traits(hasMember, T, "toHash") && 
is(typeof(T.toHash) == function)) { ... } // false

else static if (T.tupleof.length == 0) { ... } // false
else static if ((is(T == struct) && !canBitwiseHash!T) || 
T.tupleof.length == 1)//true

{
static foreach (i, F; typeof(val.tupleof))
{
static if (__traits(isStaticArray, F)) { ... } // 
false
else static if (is(F == struct) || is(F == union)) { 
... } // false

else
{
// Nothing special happening.
static if (i == 0 && !isChained)
size_t h = hashOf(val.tupleof[i]);
else
h = hashOf(val.tupleof[i], h);
}
}
}

Betcha the problem is that -preview=dip1000 causes one of the 
overloads to fail to compile, thus shuffling to a different 
overload that isn't @safe.  I hate SFINAE.


My money's on access to a private member through .tupleof.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread evilrat via Digitalmars-d-announce

On Thursday, 16 May 2019 at 01:05:53 UTC, H. S. Teoh wrote:

 ...
 I hate SFINAE.



But.. But D doesn't have it!11 NOOO!!1!




Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, May 15, 2019 at 05:53:17PM -0700, H. S. Teoh via Digitalmars-d-announce 
wrote:
> On Wed, May 15, 2019 at 11:34:44AM -0700, Walter Bright via 
> Digitalmars-d-announce wrote:
> > On 5/15/2019 11:09 AM, H. S. Teoh wrote:
> > > *Why* putting 'private' on a field member makes toHash unsafe, is
> > > beyond my ability to comprehend.
> > 
> > That's because the reduced version isn't a reduced version. It
> > imports a vast amount of other code.
> 
> Alright, here's a TRULY reduced version:

Gah, so apparently .hashOf is a gigantic overload set of *21* different
overloads, so this is not really "truly" reduced. =-O

Anybody up for figuring out which overload(s) is/are getting called?
Betcha the problem is that -preview=dip1000 causes one of the overloads
to fail to compile, thus shuffling to a different overload that isn't
@safe.  I hate SFINAE.


T

-- 
Just because you survived after you did it, doesn't mean it wasn't stupid!


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, May 15, 2019 at 11:34:44AM -0700, Walter Bright via 
Digitalmars-d-announce wrote:
> On 5/15/2019 11:09 AM, H. S. Teoh wrote:
> > *Why* putting 'private' on a field member makes toHash unsafe, is
> > beyond my ability to comprehend.
> 
> That's because the reduced version isn't a reduced version. It imports
> a vast amount of other code.

Alright, here's a TRULY reduced version:


struct S {
private int _x;
}
struct RedBlackTree
{
size_t toHash() nothrow @safe
{
return .hashOf(S.init);
}
}
void main() { }


Compiling with -preview=dip1000 causes a compile error complaining that
toHash() is not @safe.  Removing 'private' makes it go away. Compiling
without -preview=dip1000 also makes it go away.

Now explain this one. :-D


T

-- 
A linguistics professor was lecturing to his class one day. "In
English," he said, "A double negative forms a positive. In some
languages, though, such as Russian, a double negative is still a
negative. However, there is no language wherein a double positive can
form a negative." A voice from the back of the room piped up, "Yeah,
yeah."


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Walter Bright via Digitalmars-d-announce

On 5/15/2019 11:09 AM, H. S. Teoh wrote:

*Why* putting 'private' on a field member makes toHash unsafe, is beyond
my ability to comprehend.


That's because the reduced version isn't a reduced version. It imports a vast 
amount of other code.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, May 15, 2019 at 11:09:01AM -0700, H. S. Teoh via Digitalmars-d-announce 
wrote:
> On Wed, May 15, 2019 at 12:39:05AM -0700, Walter Bright via 
> Digitalmars-d-announce wrote:
> > https://github.com/dlang/phobos/pull/6931
> > 
> > This is a major milestone in improving the memory safety of D
> > programming.  Thanks to everyone who helped with this!
> > 
> > Time to start compiling your projects with DIP1000, too!
> 
> My very first attempt to compile my code with -preview=dip1000 led to
> a regression. :-(
[...]

Bugzilla issue:

https://issues.dlang.org/show_bug.cgi?id=19877


T

-- 
To err is human; to forgive is not our policy. -- Samuel Adler


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, May 15, 2019 at 12:39:05AM -0700, Walter Bright via 
Digitalmars-d-announce wrote:
> https://github.com/dlang/phobos/pull/6931
> 
> This is a major milestone in improving the memory safety of D
> programming.  Thanks to everyone who helped with this!
> 
> Time to start compiling your projects with DIP1000, too!

My very first attempt to compile my code with -preview=dip1000 led to a
regression. :-(

Reduced code:
--
import std.container.rbtree;
alias Grid = RedBlackTree!(GridPoint);
struct GridPoint
{
private string _srcStr;
int opCmp(in GridPoint p) const { return 0; }
}
--

Compiler output (with -preview=dip1000):
--
/usr/src/d/phobos/std/container/rbtree.d(): Error: `@safe` function 
`std.container.rbtree.RedBlackTree!(GridPoint, "a < b", 
false).RedBlackTree.toHash` cannot call `@system` function 
`core.internal.hash.hashOf!(GridPoint).hashOf`
/usr/src/d/druntime/import/core/internal/hash.d(510):
`core.internal.hash.hashOf!(GridPoint).hashOf` is declared here
numid.d(3): Error: template instance 
`std.container.rbtree.RedBlackTree!(GridPoint, "a < b", false)` error 
instantiating
--

The culprit is the 'private' in GridPoint.  Removing 'private' gets rid
of the problem.

*Why* putting 'private' on a field member makes toHash unsafe, is beyond
my ability to comprehend.


T

-- 
Windows: the ultimate triumph of marketing over technology. -- Adrian von Bidder


Re: Static Webpages of Forum Threads

2019-05-15 Thread Vladimir Panteleev via Digitalmars-d-announce

On Monday, 13 May 2019 at 07:40:37 UTC, Johannes Loher wrote:
I still think that we should make them easily available from 
either the website or the forums.


On the forum front page, in the right column, you will find an 
"Archive" link.


I believe Mike already mentioned that during the AGM. Is there 
anybody already working on that?


I wasn't at this year's DConf. Could you please explain what's 
lacking in the HTML pages generated by the forum software?




Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Kagamin via Digitalmars-d-announce

On Wednesday, 15 May 2019 at 07:56:48 UTC, Walter Bright wrote:

Maybe the clock is not synchronized somewhere.


It's off by one hour.


Re: bool (was DConf 2019 AGM Livestream)

2019-05-15 Thread Jonathan M Davis via Digitalmars-d-announce
On Tuesday, May 14, 2019 7:15:43 PM MDT Andrei Alexandrescu via Digitalmars-
d-announce wrote:
> On 5/14/19 2:00 AM, Mike Franklin wrote:
> > On Wednesday, 15 May 2019 at 00:23:44 UTC, Andrei Alexandrescu wrote:
> >> There are many clowny things in D, of which bool is at best somewhere
> >> beyond the radar. I suggest investing time * expertise in the larger
> >> ones.
> >
> > Once again, I disagree with what you think is important.  `bool` is a
> > fundamental type on which many things in D depend.
>
> I'd be hard pressed to find my style cramped by D's bool.

There are well-known issues where the current behavior causes bugs, and
personally, I'd prefer that the DIP have been accepted, but I have to agree
that it isn't a big problem. It's basically just one of those small warts in
the language that it would be nice to have fixed, and a number of the people
who come to D looking for a better language seem to want it to be absolutely
perfect and want every minor issue fixed. Unfortunately, while that would be
nice, it really isn't practical. Every language has warts, and if something
like this were the worst issue that D had, then we'd be _very_ well off.

> > If it doesn't work
> > right, neither will the features that depend on it.
> > But, that's your
> > decision, and there's little to nothing we can do about it, so I guess
> > we just accept the fact that D is clowny and deal with it; it's what so
> > many of us, so often do.
>
> (At any rate, going forward it's not me who needs convincing.) In my
> humble opinion, any language would have minor quirks, and a landmark of
> good engineering is attacking the right problems. That we even discuss
> just how bad bool is while we have no done deals for safety, reference
> counting, shared, package distribution/versioning, pay-as-you-go
> runtime, collections, ..., is a fascinating puzzle.

I think that in this case, it's a combination of it being a form of
bikeshedding (since the DIP is on an issue that's easy to understand and
have an opinion on) and that a DIP was written up for it and rejected. So,
some of the folks who disagree with the decison want to debate it and
somehow get a different decision.

In general though, I think that the problem with tackling harder problems
like ref-counting or shared or whatever is simply that it takes a lot more
time and effort, and most people either don't have that kind of time or
don't want to spend it on a hard problem (assuming that they even have
enough expertise to do so in the first place). It's easy to point out and
debate a small problem like how bool is treated like an integral type when
many of us don't think that that it should ever be treated as an integral
type, but it's much harder and more time-consuming to tackle the larger
problems. So, unfortunately, the harder problems are too frequently left by
the wayside. And as I'm sure you can attest to, even those of us who might
consider tackling the harder problems have enough on our plates already that
even if an issue is on our TODO list, it can easily be drowned out by other
issues.

Regardless, as a group, we do need to find ways to better tackle some of our
larger, more pressing problems. The small stuff does matter, and it's easier
to tackle, but if we're consistently trying to solve the small problems
without tackling the larger ones, then we have a serious problem.

- Jonathan M Davis





Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread M.M. via Digitalmars-d-announce

On Wednesday, 15 May 2019 at 07:39:05 UTC, Walter Bright wrote:

https://github.com/dlang/phobos/pull/6931

This is a major milestone in improving the memory safety of D 
programming. Thanks to everyone who helped with this!


Time to start compiling your projects with DIP1000, too!


Congratulations to the whole team behind it.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Walter Bright via Digitalmars-d-announce

On 5/15/2019 12:21 AM, Dukc wrote:
Could be worth a try even without docs, but in the long run we definitely need 
some explaining.


True, but I've tried fairly hard with the error messages. Please post your 
experiences with them.


Also, there shouldn't be any caveats with using it. If it passes the compiler, 
it should be good to go. (Much like const and pure.)


In general, if you find the error messages baffling, try reducing your code to a 
simpler example. This usually makes the problem clearer. dustmite is a great 
tool to help with that.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Dukc via Digitalmars-d-announce

On Wednesday, 15 May 2019 at 08:26:23 UTC, Walter Bright wrote:


This is a good start:

http://dconf.org/2017/talks/bright.html


Ah, at least something. Thanks.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Walter Bright via Digitalmars-d-announce

On 5/14/2019 11:49 PM, Dukc wrote:
About -DIP1000, I sure want to use it. But is there currently any practical way 
to learn it's usage without researching compiler source code?


This is a good start:

http://dconf.org/2017/talks/bright.html


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Dukc via Digitalmars-d-announce

On Wednesday, 15 May 2019 at 07:56:48 UTC, Walter Bright wrote:
About -DIP1000, I sure want to use it. But is there currently 
any practical way to learn it's usage without researching 
compiler source code?


Simply add the switch -preview=dip1000 to your builds, and 
follow where it leads.


Bound to cause bad practices without nothing to tell why it works 
how it works. How do I know when I'm supposed to add `scope`? Or 
how to react when the compiler complains about escaping 
references? I have some basic image in my head formed from your 
DIP paper, but I read somewhere that it's outdated.


Could be worth a try even without docs, but in the long run we 
definitely need some explaining.


Re: Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Dukc via Digitalmars-d-announce

On Wednesday, 15 May 2019 at 07:39:05 UTC, Walter Bright wrote:

https://github.com/dlang/phobos/pull/6931

This is a major milestone in improving the memory safety of D 
programming. Thanks to everyone who helped with this!


Time to start compiling your projects with DIP1000, too!


For me, the forum claims that your posting time is "from the 
future". Does that mean that is has somehow leaked a draft and 
this shouldn't show yet?


About -DIP1000, I sure want to use it. But is there currently any 
practical way to learn it's usage without researching compiler 
source code?


Phobos is now compiled with -preview=dip1000

2019-05-15 Thread Walter Bright via Digitalmars-d-announce

https://github.com/dlang/phobos/pull/6931

This is a major milestone in improving the memory safety of D programming. 
Thanks to everyone who helped with this!


Time to start compiling your projects with DIP1000, too!