using regex at compile time errors out! Error: static variable `thompsonFactory` cannot be read at compile time

2019-10-03 Thread Brett via Digitalmars-d-learn
auto r = replaceAll!((C) { return "X"; } )(s, regex(`Y`)); Error: static variable `thompsonFactory` cannot be read at compile time This is

Re: Saving and loading large data sets easily and efficiently

2019-10-03 Thread Brett via Digitalmars-d-learn
On Thursday, 3 October 2019 at 14:38:35 UTC, Bastiaan Veelo wrote: On Monday, 30 September 2019 at 20:10:21 UTC, Brett wrote: [...] The way the data is structured is that I have a master array of non-ptr structs. E.g., S[] Data; S*[] OtherStuff; then every pointer points to an element in to

Re: Saving and loading large data sets easily and efficiently

2019-10-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 30 September 2019 at 20:10:21 UTC, Brett wrote: [...] The way the data is structured is that I have a master array of non-ptr structs. E.g., S[] Data; S*[] OtherStuff; then every pointer points to an element in to Data. I did not use int's as "pointers" for a specific

Re: How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread rikki cattermole via Digitalmars-d-learn
On 04/10/2019 3:13 AM, IGotD- wrote: According to the GC documentation this code snippet char* p = new char[10]; char* q = p + 6; // ok q = p + 11;  // error: undefined behavior q = p - 1;   // error: undefined behavior suggests that char *p is really a "fat pointer" with size

Re: How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 3 October 2019 at 14:13:55 UTC, IGotD- wrote: According to the GC documentation this code snippet char* p = new char[10]; char* q = p + 6; // ok q = p + 11; // error: undefined behavior q = p - 1; // error: undefined behavior suggests that char *p is really a "fat

Re: How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 October 2019 at 14:13:55 UTC, IGotD- wrote: suggests that char *p is really a "fat pointer" with size information. D pointers are plain naked pointers. What that doc segment is saying is it works like C - in-bounds arithmetic will work, out of bounds is undefined behavior. You

How does D distnguish managed pointers from raw pointers?

2019-10-03 Thread IGotD- via Digitalmars-d-learn
According to the GC documentation this code snippet char* p = new char[10]; char* q = p + 6; // ok q = p + 11; // error: undefined behavior q = p - 1; // error: undefined behavior suggests that char *p is really a "fat pointer" with size information. However, if get some memory

Re: must scope for delegates restrict compilation?

2019-10-03 Thread Daniel Kozak via Digitalmars-d-learn
On Thu, Oct 3, 2019 at 2:00 PM Oleg B via Digitalmars-d-learn wrote: > > Hello all > > I think this code must get compilation error, but it didn't, > furthermore result program get UB. > > https://run.dlang.io/is/Qpr278 > > Is this correct behavior and why? when you change it a litle it seems

Re: must scope for delegates restrict compilation?

2019-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 October 2019 at 11:56:55 UTC, Oleg B wrote: I think this code must get compilation error, but it didn't, furthermore result program get UB. Indeed, the spec allows the compiler to issue an error, but doesn't require it. tbh it was due to difficulty in implementing the compile

must scope for delegates restrict compilation?

2019-10-03 Thread Oleg B via Digitalmars-d-learn
Hello all I think this code must get compilation error, but it didn't, furthermore result program get UB. https://run.dlang.io/is/Qpr278 Is this correct behavior and why?

Re: Using algorithms with ranges

2019-10-03 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 08:52:22 UTC, Andrea Fontana wrote: On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r =

Re: Using algorithms with ranges

2019-10-03 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 08:52:22 UTC, Andrea Fontana wrote: On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r =

Re: Using algorithms with ranges

2019-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r = iota(1,10).withHistory; writeln(r.front); writeln(r.front);

Re: Struct initialization has no effect or error?

2019-10-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 2, 2019 11:48:46 PM MDT Mike Parker via Digitalmars-d- learn wrote: > On Thursday, 3 October 2019 at 04:57:44 UTC, mipri wrote: > > On Thursday, 3 October 2019 at 04:33:26 UTC, Brett wrote: > >> I was trying to avoid such things since X is quite long in > >> name. Not a huge