Re: @safe question

2022-01-09 Thread Paul Backus via Digitalmars-d-learn
On Monday, 10 January 2022 at 01:16:31 UTC, forkit wrote: On Sunday, 9 January 2022 at 21:56:05 UTC, Salih Dincer wrote: Try the @trusted and in/out: ... .. . thanks for introducing me to the in/out feature of D :-) I'll certainly look into that feature more. But my question still remains:

Re: @safe question

2022-01-09 Thread forkit via Digitalmars-d-learn
On Sunday, 9 January 2022 at 21:56:05 UTC, Salih Dincer wrote: Try the @trusted and in/out: ... .. . thanks for introducing me to the in/out feature of D :-) I'll certainly look into that feature more. But my question still remains: //pointers ~= &str; // why is this *not* allowed in @safe

Re: @safe question

2022-01-09 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 9 January 2022 at 20:58:05 UTC, forkit wrote: Do not understand why one line is not considered @safe, but the other is. // module test; import std; @safe void main() { immutable string[] strings = ["one", "one", "two"]; immutable(string)*[] pointers = null; forea

@safe question

2022-01-09 Thread forkit via Digitalmars-d-learn
Do not understand why one line is not considered @safe, but the other is. // module test; import std; @safe void main() { immutable string[] strings = ["one", "one", "two"]; immutable(string)*[] pointers = null; foreach(size_t i, ref str; strings) { if(str == "on

Re: srand in D

2022-01-09 Thread kdevel via Digitalmars-d-learn
On Sunday, 9 January 2022 at 03:15:02 UTC, Ali Çehreli wrote: What would work in the code above is 'choice': char q = choice(allowed_chars); But that hits another fact of D: arrays of chars are strings, which cannot be RandomAccessRange because individual chars must be decoded to form dchar