Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/8/20 7:39 PM, realhet wrote: On Sunday, 9 February 2020 at 00:15:47 UTC, Drug wrote: On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: Hello, class A{   int i = 42; } Is there a way to get that 42? (Input is the class A and the name of the field 'i') A.i.init returns 0, so

Re: Flatten a range of static arrays

2020-02-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/8/20 1:20 PM, ag0aep6g wrote: On 08.02.20 15:57, Steven Schveighoffer wrote: This kind of stuff is so difficult to reason about and develop as a library that people will just end up removing dip1000 from their compilation. I 100% agree that DIP 1000 is hard to reason about. It's pretty

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 9 February 2020 at 00:57:05 UTC, realhet wrote: On Sunday, 9 February 2020 at 00:41:12 UTC, realhet wrote: On Sunday, 9 February 2020 at 00:27:21 UTC, Adam D. Ruppe wrote: Using what I've learned: class A{ int i=42; void init(){ // reInitialize class fields alias T =

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread realhet via Digitalmars-d-learn
On Sunday, 9 February 2020 at 00:57:05 UTC, realhet wrote: On Sunday, 9 February 2020 at 00:41:12 UTC, realhet wrote: On Sunday, 9 February 2020 at 00:27:21 UTC, Adam D. Ruppe wrote: mixin([FieldNameTuple!T].map!(n => n~"=(new T)."~n~";").join); After checking it in the asm debugger, it

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread realhet via Digitalmars-d-learn
On Sunday, 9 February 2020 at 00:41:12 UTC, realhet wrote: On Sunday, 9 February 2020 at 00:27:21 UTC, Adam D. Ruppe wrote: Using what I've learned: class A{ int i=42; void init(){ // reInitialize class fields alias T = typeof(this); mixin([FieldNameTuple!T].map!(n => n~"=(new

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread realhet via Digitalmars-d-learn
On Sunday, 9 February 2020 at 00:27:21 UTC, Adam D. Ruppe wrote: On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: classinfo.m_init can be an option, but maybe there's a nicer way to do this? eh the initializer i think is the best. you can sometimes shortcut it pragma(msg, (new

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread realhet via Digitalmars-d-learn
On Sunday, 9 February 2020 at 00:15:47 UTC, Drug wrote: On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: Hello, class A{ int i = 42; } Is there a way to get that 42? (Input is the class A and the name of the field 'i') A.i.init returns 0, so it doesn't care about the class.

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: classinfo.m_init can be an option, but maybe there's a nicer way to do this? eh the initializer i think is the best. you can sometimes shortcut it pragma(msg, (new A).i); which will call the ctor at ctfe and get the value. but if

Re: Getting the initial value of a class field in compile time.

2020-02-08 Thread Drug via Digitalmars-d-learn
On Saturday, 8 February 2020 at 23:37:56 UTC, realhet wrote: Hello, class A{ int i = 42; } Is there a way to get that 42? (Input is the class A and the name of the field 'i') A.i.init returns 0, so it doesn't care about the class. classinfo.m_init can be an option, but maybe there's a

Getting the initial value of a class field in compile time.

2020-02-08 Thread realhet via Digitalmars-d-learn
Hello, class A{ int i = 42; } Is there a way to get that 42? (Input is the class A and the name of the field 'i') A.i.init returns 0, so it doesn't care about the class. classinfo.m_init can be an option, but maybe there's a nicer way to do this? Thx!

Re: total newbie + IDE

2020-02-08 Thread Borax Man via Digitalmars-d-learn
On Saturday, 8 February 2020 at 10:46:52 UTC, Basile B. wrote: On Saturday, 8 February 2020 at 03:59:22 UTC, Borax Man wrote: As linked before, dexed is available here https://github.com/akira13641/dexed and I compiled it just a few days ago with success. It is a fork (check the count of

Re: Flatten a range of static arrays

2020-02-08 Thread ag0aep6g via Digitalmars-d-learn
On 08.02.20 07:27, ag0aep6g wrote: On 08.02.20 02:38, ag0aep6g wrote: Simplified, we're looking at this: struct Joiner { int[3] _items; int[] _current; } void main() @safe { Joiner j; j._current = j._items[]; } [...] In the first reduction, `j` might be `scope`,

Re: How to refer to different sized static arrays

2020-02-08 Thread Ali Çehreli via Digitalmars-d-learn
On 2/8/20 12:22 AM, Adnan wrote: Just a foreword, this is for learning purposes, hence I am not using the dynamic array or Array!T. I have a structure that maintains a heap allocated sized array inside. struct LifoStack(T) {   T[?] data; } This `data` is manually resized and copied. Thus

Re: How to refer to different sized static arrays

2020-02-08 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Saturday, 8 February 2020 at 08:22:46 UTC, Adnan wrote: Just a foreword, this is for learning purposes, hence I am not using the dynamic array or Array!T. I have a structure that maintains a heap allocated sized array inside. struct LifoStack(T) { T[?] data; } T[N] is a static array

Re: Flatten a range of static arrays

2020-02-08 Thread ag0aep6g via Digitalmars-d-learn
On 08.02.20 15:57, Steven Schveighoffer wrote: This kind of stuff is so difficult to reason about and develop as a library that people will just end up removing dip1000 from their compilation. I 100% agree that DIP 1000 is hard to reason about. It's pretty limited by design, and the

Re: Flatten a range of static arrays

2020-02-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/7/20 8:38 PM, ag0aep6g wrote: If that code were allowed, you could do this: struct Joiner {     Joiner* p; } Joiner g; void main() @safe {     scope Joiner j;     () @trusted { j.p = } (); /* pretend it's allowed */     g = *j.p; /* dereference and copy */ } Returning a

Re: total newbie + IDE

2020-02-08 Thread Basile B. via Digitalmars-d-learn
On Saturday, 8 February 2020 at 03:59:22 UTC, Borax Man wrote: As linked before, dexed is available here https://github.com/akira13641/dexed and I compiled it just a few days ago with success. It is a fork (check the count of commits). The most recent version is here

Re: How to converte string to wstring[]?

2020-02-08 Thread Marcone via Digitalmars-d-learn
On Friday, 7 February 2020 at 06:20:09 UTC, novice2 wrote: import std.conv: to; string str = "test1"; wstring[] wstr = [to!wstring(str)]; Thank you!

Re: total newbie + IDE

2020-02-08 Thread Marcone via Digitalmars-d-learn
You don't need an IDE for run Dlang. I Use "Sublime Text". Very good for Dlang.

Re: D create many thread

2020-02-08 Thread Rainer Schuetze via Digitalmars-d-learn
On 07/02/2020 16:52, Steven Schveighoffer wrote: > But I still maintain, a hello world program should not need this to > avoid spawning 6 threads to scan itself. I agree, see https://issues.dlang.org/show_bug.cgi?id=20567 and https://github.com/dlang/druntime/pull/2933

How to refer to different sized static arrays

2020-02-08 Thread Adnan via Digitalmars-d-learn
Just a foreword, this is for learning purposes, hence I am not using the dynamic array or Array!T. I have a structure that maintains a heap allocated sized array inside. struct LifoStack(T) { T[?] data; } This `data` is manually resized and copied. Thus the size itself is not a compile