Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 06:20:53 UTC, Elfstone wrote: Yeah, I understand some cases are impossible, and to be avoided. I believe your example is also impossible in C++, but it's better the compiler do its job when it's totally possible - needless to say, C++ compilers can deduce my _dot_. Con

How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
This produces compatible strings between symbol and runtime type: ```d class Foo {} void main() { alias Foo F; writeln(fullyQualifiedName!F); auto f = new F; writeln(typeid(f).name); } ``` ``` test.Foo test.Foo ``` But if the class is a template, the strings differ

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote: Given a runtime typeid, how can I get the equivalent fullyQualifiedName without attempting to mangle the string myself manually? e.g. something I can pass to `Object.factory`. Actually, looking at this further, does Object.factory even suppor

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Loara via Digitalmars-d-learn
On Monday, 2 May 2022 at 17:21:53 UTC, JG wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote: [...] Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Co

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Loara via Digitalmars-d-learn
On Monday, 2 May 2022 at 19:17:19 UTC, Stanislav Blinov wrote: On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote: Template deduction for aliased function parameter is a very tricky argument and it's not so simple to handle in certain cases. Consider for example this code: ```d template

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread bauss via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 09:52:56 UTC, cc wrote: On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote: Given a runtime typeid, how can I get the equivalent fullyQualifiedName without attempting to mangle the string myself manually? e.g. something I can pass to `Object.factory`. Actually, looki

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Arafel via Digitalmars-d-learn
On 3/5/22 12:48, bauss wrote: This is where compile-time has its limits compared to runtime type creation, because templates only live during compile-time then it isn't really that easy to do something like this, where it would be trivial in other languages like C#. That's something I don't r

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote: something I can pass to `Object.factory`. Object.factory is useless and will hopefully be removed someday. Instead, make your own factory registration function. Put a static constructor in the class which appends a factory delegate to an arra

Re: How to use destroy and free.

2022-05-03 Thread Alain De Vos via Digitalmars-d-learn
Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word...

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 10:48:53 UTC, bauss wrote: Object.factory calls TypeInfo_Class.find which just loops through ModuleInfo and then looks if any of the entries in localClasses has a name that matches. Afterwards it calls the create function on the TypeInfo_Class which of course isn't "

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Arafel via Digitalmars-d-learn
On 3/5/22 14:46, Adam D Ruppe wrote: Put a static constructor in the class which appends a factory delegate to an array or something you can use later. Then you can use your own thing to construct registered objects. I'd like to do a runtime registration system myself, using a "template this"

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote: Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word... It means if the compiler is free to allocate on the stack if possible. I

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 13:25:14 UTC, Arafel wrote: I'd like to do a runtime registration system myself, using a "template this" static constructor. A simple version supporting only default constructors would be: Yeah, you can't template this a static constructor, but you can just use a sta

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Arafel via Digitalmars-d-learn
On 3/5/22 15:57, Adam D Ruppe wrote: So doing things yourself gives you some control. Yes, it is indeed possible (I acknowledged it), but I think it's much more cumbersome than it should, and puts the load on the user. If templated this worked in static context (ideally everywhere else too)

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 14:38:53 UTC, Arafel wrote: Actually, it would be cool to do it through an interface, although I don't think an interface's static constructors are invoked by the implementing classes... it would be cool, though. yeah interfaces can't have constructors. I'd try it my

Re: How to use destroy and free.

2022-05-03 Thread Alain De Vos via Digitalmars-d-learn
Note, It's not i'm against GC. But my preference is to use builtin types and libraries if possible, But at the same time be able to be sure memory is given free when a variable is going out of scope. It seems not easy to combine the two with a GC which does his best effort but as he likes or not

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 03, 2022 at 04:38:53PM +0200, Arafel via Digitalmars-d-learn wrote: > On 3/5/22 15:57, Adam D Ruppe wrote: > > So doing things yourself gives you some control. > > Yes, it is indeed possible (I acknowledged it), but I think it's much > more cumbersome than it should, and puts the load

Re: How to use destroy and free.

2022-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 03, 2022 at 02:57:46PM +, Alain De Vos via Digitalmars-d-learn wrote: > Note, It's not i'm against GC. But my preference is to use builtin > types and libraries if possible, > But at the same time be able to be sure memory is given free when a > variable is going out of scope. > It

Re: How to use destroy and free.

2022-05-03 Thread Ali Çehreli via Digitalmars-d-learn
On 5/3/22 07:57, Alain De Vos wrote: > But at the same time be able to be sure memory is given free when a > variable is going out of scope. Let's expand on that please. What exactly is the worry there? Are you concerned that the program will have memory leaks, and eventually got killed by the

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Arafel via Digitalmars-d-learn
On 3/5/22 16:48, Adam D Ruppe wrote: Believe it or not, you don't need to touch the compiler. Open your druntime's object.d and search for `RTInfo` http://druntime.dpldocs.info/object.RTInfo.html That is instantiated for every user defined type in the program and you have the compile time inf

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ali Çehreli via Digitalmars-d-learn
On 5/2/22 13:36, Stanislav Blinov wrote: >> That's fine because D does not promise to solve such problems. It >> follows simple deduction rules. > > Words, dear guru. Words have a meaning. It is very possible to deduce > here (note the premise). D just isn't trying. That's what I said. Yo

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote: class Base : Serializable!(Base) { ... } class Derived : Serializable!(Base, Derived) { ... } This is really interesting syntax, I'm surprised that works!

Re: How to use destroy and free.

2022-05-03 Thread Tejas via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote: Error: array literal in @nogc function test.myfun may cause a GC allocation @nogc void myfun(){ scope int[] i=[1,2,3]; }//myfun May is a fuzzy word... For this particular piece of code, you can use a static array to guarant

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 03, 2022 at 04:38:23PM +, cc via Digitalmars-d-learn wrote: > On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote: > > class Base : Serializable!(Base) { ... } > > class Derived : Serializable!(Base, Derived) { ... } > > This is really interesting syntax, I'm surprised

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 16:38:23 UTC, cc wrote: This is really interesting syntax, I'm surprised that works! Can read a little more on my blog about it: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_06_10.html#tip-of-the-week pretty cool little pattern.

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 16:51:33 UTC, H. S. Teoh wrote: On Tue, May 03, 2022 at 04:38:23PM +, cc via Digitalmars-d-learn wrote: On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote: >class Base : Serializable!(Base) { ... } >class Derived : Serializable!(Base, Derived) { ... }

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 03, 2022 at 04:59:42PM +, cc via Digitalmars-d-learn wrote: > On Tuesday, 3 May 2022 at 16:51:33 UTC, H. S. Teoh wrote: [...] > > > On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote: > > > > class Base : Serializable!(Base) { ... } > > > > class Derived : Seri

String Literals

2022-05-03 Thread JG via Digitalmars-d-learn
Hi, The specification of string literals has either some errors or I don't understand what is meant by a Character. For instance we have: WysiwygString: r" WysiwygCharacters_opt " StringPostfix_opt WysiwygCharacters: WysiwygCharacter WysiwygCharacter WysiwygCharacters WysiwygCha

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 17:05:09 UTC, H. S. Teoh wrote: Oops, sorry, I made a mistake. The definition of Serializable should be: class Serializable(Base, Derived = Object) : Base {} There we go, works with this, now I get what it's trying to do: ```d class Serializable(Base, Derived

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 03, 2022 at 05:25:06PM +, cc via Digitalmars-d-learn wrote: > On Tuesday, 3 May 2022 at 17:05:09 UTC, H. S. Teoh wrote: > > Oops, sorry, I made a mistake. The definition of Serializable should be: > > > > class Serializable(Base, Derived = Object) : Base {} > > There we go, wo

DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
I made some changes to some code I'm working on and now there are some lines that are giving me funky DMD error codes (I can tell it is some lines because I comment them out and the errors go away). So for instance, one line I have a static assert that gives an error code -1073741819, but if I

Re: DMD failed with exit code -1073741819

2022-05-03 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: I was leaning towards it being something related to running out of memory or something, but I'm using dub and I've tried turning on and off "lowmem". Note that dub cannot pass -lowmem to dmd. https://issues.dlang.org/show_bug.cgi?id=20699

Re: DMD failed with exit code -1073741819

2022-05-03 Thread Dennis via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: Does anyone have any idea what causes these types of errors? Sounds like a stack overflow, maybe your code has a complex/recursive part that makes DMD's call stack very deep.

Re: DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 19:03:56 UTC, Dennis wrote: On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: Does anyone have any idea what causes these types of errors? Sounds like a stack overflow, maybe your code has a complex/recursive part that makes DMD's call stack very deep. Thanks.

Re: String Literals

2022-05-03 Thread user1234 via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 17:21:47 UTC, JG wrote: Hi, The specification of string literals has either some errors or I don't understand what is meant by a Character. [...] Which to me means that e.g. r""" should be a WysiwygString, which the compiler thinks is not (not surprisingly). Am I m

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-03 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 15:41:08 UTC, Ali Çehreli wrote: We also have NP-completeness. Ok, so C++ has similar limitations when you have a template with an unknown parameter in a function parameter, but is this because it would be NPC? Also, do we know that it cannot be resolved for the typ

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote: Note, It's not i'm against GC. But my preference is to use builtin types and libraries if possible, But at the same time be able to be sure memory is given free when a variable is going out of scope. It seems not easy to combine the two

Re: How to use destroy and free.

2022-05-03 Thread forkit via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 02:42:44 UTC, Mike Parker wrote: On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote: Note, It's not i'm against GC. But my preference is to use builtin types and libraries if possible, But at the same time be able to be sure memory is given free when a variab

Re: How to use destroy and free.

2022-05-03 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote: It is certainly *not* about you not having to care anymore (about memory management). That's not at all what I said. You don't have to care about *when* memory is deallocated, meaning you don't have to manage it yourself.

Re: How to use destroy and free.

2022-05-03 Thread forkit via Digitalmars-d-learn
On Wednesday, 4 May 2022 at 05:13:04 UTC, Mike Parker wrote: On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote: It is certainly *not* about you not having to care anymore (about memory management). That's not at all what I said. You don't have to care about *when* memory is dealloca