July 25, 2013
On Wednesday, July 24, 2013 19:28:41 Iain Buclaw wrote:
> Incase someone hasn't already pointed out. Bounds checking is *always* done in @safe code. :)

Not if you use -noboundscheck. The whole point of its existence is to disable bounds checking in @safe code. -release disables bounds checking in non-@safe code, and -noboundscheck disables it in everything.

- Jonathan m Davis
July 25, 2013
On Thursday, 25 July 2013 at 00:09:40 UTC, Jonathan M Davis wrote:
> On Thursday, July 25, 2013 01:29:04 John Colvin wrote:
>> And @safe is automatically inferred (on templates only still?)
>> when possible? I don't like where this is going...
>
> If you have code that you want to be explictly @system, then mark it with
> @system. That will override any attribute inference for @safe.
>
> - Jonathan m Davis

Last time I checked: Adding a *single* qualification on a function will deactivate inference for *every* qualifier. Is this still true?

Is there any documentation about how inference works, I can't find it.
July 25, 2013
On Wednesday, 24 July 2013 at 11:32:17 UTC, bearophile wrote:
> Compiling with LDC2 I have found Xorshift about as fast as C rand :-)

Minor point, but it may be worth checking the number of bits used in different languages' Xorshifts. For D the default is 128. If others use less (or more) they may be faster (or slower).
July 25, 2013
On Thursday, 25 July 2013 at 00:09:40 UTC, Jonathan M Davis wrote:
> On Thursday, July 25, 2013 01:29:04 John Colvin wrote:
>> And @safe is automatically inferred (on templates only still?)
>> when possible? I don't like where this is going...
>
> If you have code that you want to be explictly @system, then mark it with
> @system. That will override any attribute inference for @safe.
>
> - Jonathan m Davis

That isn't really a good solution for the general case.

Could dmd perhaps mark a function inferred to be safe as @trusted instead of @safe? Or would that break other stuff?
July 25, 2013
On Thursday, 25 July 2013 at 10:00:53 UTC, John Colvin wrote:
> On Thursday, 25 July 2013 at 00:09:40 UTC, Jonathan M Davis wrote:
>> On Thursday, July 25, 2013 01:29:04 John Colvin wrote:
>>> And @safe is automatically inferred (on templates only still?)
>>> when possible? I don't like where this is going...
>>
>> If you have code that you want to be explictly @system, then mark it with
>> @system. That will override any attribute inference for @safe.
>>
>> - Jonathan m Davis
>
> That isn't really a good solution for the general case.
>
> Could dmd perhaps mark a function inferred to be safe as @trusted instead of @safe? Or would that break other stuff?

woops, sorry, just saw your message below saying that -noboundscheck does actually disable it in @safe
July 25, 2013
On Thursday, 25 July 2013 at 08:13:07 UTC, Joseph Rushton Wakeling wrote:
> On Wednesday, 24 July 2013 at 11:32:17 UTC, bearophile wrote:
>> Compiling with LDC2 I have found Xorshift about as fast as C rand :-)
>
> Minor point, but it may be worth checking the number of bits used in different languages' Xorshifts. For D the default is 128. If others use less (or more) they may be faster (or slower).

Just checked the code -- the C and Go versions are using 32-bit Xorshift so it's still not a fair comparison (didn't check for Rust). Could try with Xorshift32 (or bump the C/C++/Go/Rust versions to 128-bit).

But before doing that -- has the Xorshift32 bug fix made it to LDC yet?

Last observation -- could some of the LLVM vs. GCC difference be down to LLVM backends outputting native as opposed to generic executables?
July 25, 2013
On Thursday, 25 July 2013 at 10:34:56 UTC, Joseph Rushton Wakeling wrote:
> Just checked the code

... not thoroughly enough. D.d in the GitHub repo is using the same handwritten 32-bit Xorshift as the C and Go code.
July 25, 2013
On Thursday, 25 July 2013 at 10:52:58 UTC, Joseph Rushton Wakeling wrote:
> On Thursday, 25 July 2013 at 10:34:56 UTC, Joseph Rushton Wakeling wrote:
>> Just checked the code
>
> ... not thoroughly enough. D.d in the GitHub repo is using the same handwritten 32-bit Xorshift as the C and Go code.

Is this a big problem performance wise though? I mean, the bug was *only* that the first few iteration were "not so random", is this correct? This fix didn't really change the computational cost of the operation, did it?

I mean, it's a problem as far as randomness goes, but for a simple bench, I don't think it is much of a problem.
July 25, 2013
On Thursday, July 25, 2013 08:56:40 monarch_dodra wrote:
> On Thursday, 25 July 2013 at 00:09:40 UTC, Jonathan M Davis wrote:
> > On Thursday, July 25, 2013 01:29:04 John Colvin wrote:
> >> And @safe is automatically inferred (on templates only still?) when possible? I don't like where this is going...
> > 
> > If you have code that you want to be explictly @system, then
> > mark it with
> > @system. That will override any attribute inference for @safe.
> > 
> > - Jonathan m Davis
> 
> Last time I checked: Adding a *single* qualification on a function will deactivate inference for *every* qualifier. Is this still true?

I have no idea. I'd have to test it. I was not aware of that ever being the case. I'd certainly consider that to be a bug if it is.

> Is there any documentation about how inference works, I can't find it.

Not that I'm aware of.

- Jonathan M Davis
July 25, 2013
On Thursday, 25 July 2013 at 11:42:10 UTC, Jonathan M Davis wrote:
> On Thursday, July 25, 2013 08:56:40 monarch_dodra wrote:
>> On Thursday, 25 July 2013 at 00:09:40 UTC, Jonathan M Davis wrote:
>> > On Thursday, July 25, 2013 01:29:04 John Colvin wrote:
>> >> And @safe is automatically inferred (on templates only still?)
>> >> when possible? I don't like where this is going...
>> > 
>> > If you have code that you want to be explictly @system, then
>> > mark it with
>> > @system. That will override any attribute inference for @safe.
>> > 
>> > - Jonathan m Davis
>> 
>> Last time I checked: Adding a *single* qualification on a
>> function will deactivate inference for *every* qualifier. Is this
>> still true?
>
> I have no idea. I'd have to test it. I was not aware of that ever being the
> case. I'd certainly consider that to be a bug if it is.

I just tested on my end. Seems it's not the case, so I could have been mistaken. Good to know.

>> Is there any documentation about how inference works, I can't
>> find it.
>
> Not that I'm aware of.
>
> - Jonathan M Davis

Thanks.