Jump to page: 1 2
Thread overview
Compile-Time RNG
Jan 20, 2016
CTRNG
Jan 21, 2016
tsbockman
Jan 21, 2016
Timon Gehr
Jan 21, 2016
tsbockman
Jan 21, 2016
Matthias Bentrup
Jan 21, 2016
tsbockman
Jan 21, 2016
Era Scarecrow
Jan 21, 2016
Brian Schott
Mar 05, 2019
Cym13
Mar 05, 2019
Dennis
Mar 05, 2019
Stefan Koch
Mar 06, 2019
Cym13
Mar 07, 2019
Stefan Koch
January 20, 2016
I managed to create a compile-time random number generator.

Proof of concept, with some explanatory comments: http://dpaste.dzfl.pl/668646ce6d71

Just thought this might be of interest to some of you here.
January 21, 2016
On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
> I managed to create a compile-time random number generator.
>
> Proof of concept, with some explanatory comments: http://dpaste.dzfl.pl/668646ce6d71
>
> Just thought this might be of interest to some of you here.

That's clever (and devious).
January 21, 2016
On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
> I managed to create a compile-time random number generator.
>
> Proof of concept, with some explanatory comments: http://dpaste.dzfl.pl/668646ce6d71
>
> Just thought this might be of interest to some of you here.

That's nearly as fun as using the bsr and bsf functions in core.bitop to implement a pure random number generator.

https://issues.dlang.org/show_bug.cgi?id=14380
January 21, 2016
On 01/21/2016 01:32 AM, tsbockman wrote:
> On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
>> I managed to create a compile-time random number generator.
>>
>> Proof of concept, with some explanatory comments:
>> http://dpaste.dzfl.pl/668646ce6d71
>>
>> Just thought this might be of interest to some of you here.
>
> That's clever (and devious).

It only works because compile-time introspection is ill-defined though. I don't expect it to keep working indefinitely.
January 21, 2016
On Thursday, 21 January 2016 at 01:49:27 UTC, Timon Gehr wrote:
> It only works because compile-time introspection is ill-defined though. I don't expect it to keep working indefinitely.

That aspect can easily be replaced by __LINE__ and __FILE__.
January 21, 2016
On Thursday, 21 January 2016 at 07:43:13 UTC, tsbockman wrote:
> On Thursday, 21 January 2016 at 01:49:27 UTC, Timon Gehr wrote:
>> It only works because compile-time introspection is ill-defined though. I don't expect it to keep working indefinitely.
>
> That aspect can easily be replaced by __LINE__ and __FILE__.

A supported way to generate new names at compile time would be nice.
January 21, 2016
On Thursday, 21 January 2016 at 01:49:27 UTC, Timon Gehr wrote:
> On 01/21/2016 01:32 AM, tsbockman wrote:
>> On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
>>> Just thought this might be of interest to some of you here.
>>
>> That's clever (and devious).
>
> It only works because compile-time introspection is ill-defined though. I don't expect it to keep working indefinitely.

 Hmm it does seem having an RNG during compile-time would be useful, although I'm trying to come up with a use-case for when it would actually work, or how you'd use it.
January 21, 2016
On Thursday, 21 January 2016 at 09:29:38 UTC, Matthias Bentrup wrote:
>> That aspect can easily be replaced by __LINE__ and __FILE__.
>
> A supported way to generate new names at compile time would be nice.

It would, but in this particular case __LINE__ and __FILE__ actually provide a more natural way of solving the problem. The idea of generating new symbols to increment the counter is clever, but it's also an awkward hack.

__LINE__ already does pretty much what he needed by itself.
March 05, 2019
On Wednesday, 20 January 2016 at 23:21:04 UTC, CTRNG wrote:
> I managed to create a compile-time random number generator.
>
> Proof of concept, with some explanatory comments: http://dpaste.dzfl.pl/668646ce6d71
>
> Just thought this might be of interest to some of you here.

Sorry for necroposting but does anyone have that POC? dpaste.dzfl.pl seems down.

I'm currently facing a case where I would very much like to have random data at compile-time and I can't find a way to get them.

Also the core.bitopt.bsf bug mentionned later in the thread was fixed so no luck there (and the bug report is still open, I think it should be closed).
March 05, 2019
On Tuesday, 5 March 2019 at 21:22:55 UTC, Cym13 wrote:
> Sorry for necroposting but does anyone have that POC?

It's on the D idioms list
https://p0nce.github.io/d-idioms/#Compile-time-RNG
« First   ‹ Prev
1 2