Mir Random [WIP]

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 24 09:04:43 PST 2016


On Thursday, 24 November 2016 at 16:09:23 UTC, Ilya Yaroshenko 
wrote:
> On Thursday, 24 November 2016 at 13:45:40 UTC, Jonathan M Davis 
> wrote:
>> Alternatively, you could just do rndGen().take(1).front, and 
>> as long as rndGen() gives you a reference type, it works just 
>> fine. Unfortunately, std.random did not use reference types 
>> for its ranges. _That_ is the big mistake of std.random and 
>> the main item that needs to be fixed. There are some other 
>> subtleties (e.g. it's useful to be able to save the state of a 
>> random number generating range, but you don't necessarily 
>> really want it to be a forward range), but those are minor in 
>> comparison to the mistake of std.random using value types 
>> rather than reference types for ranges.
>>
>> - Jonathan M Davis
>
> The fix is opCall syntax. Reference types are classes, which 
> would not work without linking DRuntime and Phobos (BetterC).

If druntime was initialised by default using 
__attribute__((constructor)) for static and linker .init for 
shared libraries, would that be good enough for you*? I feel like 
you're limiting your design choices because of a relatively small 
and simple implementation shortcoming.

* remember, we don't currently guarantee ABI compatibility 
between compiler versions even if you don't use druntime/phobos.


More information about the Digitalmars-d mailing list