Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread ag0aep6g via Digitalmars-d-learn
On 12.07.21 03:37, someone wrote: I ended up with the following (as usual advice/suggestions welcomed): [...]> alias stringUTF16 = dstring; /// same as immutable(dchar)[];> alias stringUTF32 = wstring; /// same as immutable(wchar)[]; Bug: You mixed up `wstring` and `dstring`. `wstring` is UTF-16

Re: How do I check if a variable is a multidimensional (2D) array?

2021-07-11 Thread Kirill via Digitalmars-d-learn
On Monday, 12 July 2021 at 05:08:29 UTC, jfondren wrote: On Monday, 12 July 2021 at 04:25:00 UTC, Kirill wrote: I know there is isArray!T and similar functionality in std.traits. But I couldn't find the functionality that can help me check if I have a multidimensional array. Is there any? How

Re: How do I check if a variable is a multidimensional (2D) array?

2021-07-11 Thread jfondren via Digitalmars-d-learn
On Monday, 12 July 2021 at 04:25:00 UTC, Kirill wrote: I know there is isArray!T and similar functionality in std.traits. But I couldn't find the functionality that can help me check if I have a multidimensional array. Is there any? How do I create my own? Thanks in advance. from https://gi

How do I check if a variable is a multidimensional (2D) array?

2021-07-11 Thread Kirill via Digitalmars-d-learn
I know there is isArray!T and similar functionality in std.traits. But I couldn't find the functionality that can help me check if I have a multidimensional array. Is there any? How do I create my own? Thanks in advance.

Re: Trivial simple OpenGl working example

2021-07-11 Thread Виталий Фадеев via Digitalmars-d-learn
On Saturday, 10 July 2021 at 19:43:07 UTC, Danny Arends wrote: On Saturday, 10 July 2021 at 12:41:19 UTC, Виталий Фадеев wrote: [...] Just disable shader compilation using dub, the shader only needs to be compiled once. Since you're on linux it fails to execute glslc.exe (the windows executa

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 05:54:48 UTC, Ali Çehreli wrote: Ali Primarily to Ali & Steve for their help, be advised, this post will be somehow ... long. Some bit of background to begin with: a week or so ago I posted asking advice on code safeness, and still I didn't reply to the ones tha

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:49:28 UTC, Adam D Ruppe wrote: Indeed, you'd have to mixin the whole thing like mixin("public struct " ~ lstrStructureId ~ " { ... } "); As I mentioned in my previous reply to Ali this could be viable for one-liners-or-so, but for chunks of code having, say, a

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread someone via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:14:23 UTC, Steven Schveighoffer wrote: when I've done this kind of stuff, what I usually do is: ```d struct Thing { ... // actual struct } mixin("alias ", lstrStructureID, " = Thing;"); ``` the downside is that the actual struct name symbol will be `Thing`, o

Re: catching segfault using try_ catch

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 23:34:38 UTC, seany wrote: Is there an example i can use Thank you. You just call the registerMemoryHandler() function from that module at some point in your main function before doing other work.

Re: catching segfault using try_ catch

2021-07-11 Thread seany via Digitalmars-d-learn
On Sunday, 11 July 2021 at 21:15:30 UTC, Paul Backus wrote: I know it's possible on Linux using the `etc.linux.memoryerror` module [1]. Not sure about Windows. Linux would be sufficient. Is there an example i can use Thank you.

Re: catching segfault using try_ catch

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 21:15:30 UTC, Paul Backus wrote: I know it's possible on Linux using the `etc.linux.memoryerror` module [1]. Not sure about Windows. With -m32, it just works. With -m32mscoff I'm not sure. With -m64, as far as I know, there is no way.

Re: catching segfault using try_ catch

2021-07-11 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 11 July 2021 at 20:18:18 UTC, seany wrote: Is it possible to catch a segfault - using try/catch loop? Thank you I know it's possible on Linux using the `etc.linux.memoryerror` module [1]. Not sure about Windows. [1] https://druntime.dpldocs.info/etc.linux.memoryerror.html

catching segfault using try_ catch

2021-07-11 Thread seany via Digitalmars-d-learn
Is it possible to catch a segfault - using try/catch loop? Thank you

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 July 2021 at 14:04:14 UTC, zjh wrote: just genenrate `lstrStructureID` struct.

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread zjh via Digitalmars-d-learn
```d mixin template templateUGC ( typeStringUTF, alias lstrStructureID){ public struct lstrStructureID { typeStringUTF w; } } mixin templateUGC!(string, "gudtUGC08"); ``` You say `This creates a struct with teh literal name lstrStructureID`. I tried,can compile,but I don't know ge

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:30:27 UTC, zjh wrote: Could you explain more detail? It is just normal code with a normal name. The fact there's another variable with the same name doesn't change anything.

Re: Can I get the time "Duration" in "nsecs" acurracy?

2021-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/9/21 5:13 PM, rempas wrote: On Friday, 9 July 2021 at 20:54:21 UTC, Paul Backus wrote: On Friday, 9 July 2021 at 20:43:48 UTC, rempas wrote: I'm reading the library reference for [core.time](https://dlang.org/phobos/core_time.html#Duration) and It says that the duration is taken in "hnsec

Re: Scope of enum

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:21:35 UTC, DLearner wrote: Is there a 'D' way of avoiding the issue? Pass the size as a parameter to the thing instead of trying to combine things. like mixin template Thing(size_t size) { ubyte[size] pool; } and where you want it like mixin Thing!(100);

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:49:28 UTC, Adam D Ruppe wrote: This creates a struct with teh literal name `lstrStructureID`. Just like any other name. So it is NOT the value of the variable. Could you explain more detail?

Re: Scope of enum

2021-07-11 Thread DLearner via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:47:48 UTC, Adam D Ruppe wrote: On Sunday, 11 July 2021 at 12:37:20 UTC, DLearner wrote: C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type k_mod.d // k_mod.d ubyte[MemSiz] MemPool; You didn't import the other module here. D's imports aren't like C's inclu

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/11/21 8:49 AM, Adam D Ruppe wrote: On Sunday, 11 July 2021 at 05:20:49 UTC, someone wrote: ```d mixin template templateUGC (    typeStringUTF,    alias lstrStructureID    ) {    public struct lstrStructureID {   typeStringUTF whatever;    } This creates a struct with teh literal n

Re: assert(false) and GC

2021-07-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/10/21 12:32 PM, Mathias LANG wrote: On Saturday, 10 July 2021 at 01:38:06 UTC, russhy wrote: On Saturday, 10 July 2021 at 01:23:26 UTC, Steven Schveighoffer wrote: I think it's the throwing/catching of the `Throwable` that is allocating. But I don't know from where the allocation happens

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 05:20:49 UTC, someone wrote: ```d mixin template templateUGC ( typeStringUTF, alias lstrStructureID ) { public struct lstrStructureID { typeStringUTF whatever; } This creates a struct with teh literal name `lstrStructureID`. Just like any oth

Re: Scope of enum

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:37:20 UTC, DLearner wrote: C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type k_mod.d // k_mod.d ubyte[MemSiz] MemPool; You didn't import the other module here. D's imports aren't like C's includes. Each module is independent and can only see what it itse

Re: Scope of enum

2021-07-11 Thread DLearner via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:01:27 UTC, jfondren wrote: On Sunday, 11 July 2021 at 10:58:58 UTC, DLearner wrote: Is there a way of forcing DMD to extend the scope of `MemSiz` to include `k_mod`? Best regards ``` $ cat k_mod.d import test01; ubyte[MemSiz] MemPool; $ cat test01.d enum MemSi

Re: Scope of enum

2021-07-11 Thread jfondren via Digitalmars-d-learn
On Sunday, 11 July 2021 at 10:58:58 UTC, DLearner wrote: Is there a way of forcing DMD to extend the scope of `MemSiz` to include `k_mod`? Best regards ``` $ cat k_mod.d import test01; ubyte[MemSiz] MemPool; $ cat test01.d enum MemSiz = 240; void main() { import std.stdio, k_mod; w

Scope of enum

2021-07-11 Thread DLearner via Digitalmars-d-learn
Please see the two code snippets below: ``` // test01.d enum MemSiz = 240; void main() { import k_mod; } ``` and ``` // k_mod.d ubyte[MemSiz] MemPool; ``` A number of tests need to be run on code in `k_mod`, with different sizes of the static array `MemPool` in each test. So each test

Re: Sumtype warning

2021-07-11 Thread jfondren via Digitalmars-d-learn
On Sunday, 11 July 2021 at 09:20:23 UTC, JG wrote: I am getting the following message: Warning: struct SumType has method toHash, however it cannot be called with const(SumType!(A,B,C)) this Could someone point in the right direction to understand what I am doing that causes this? The two r

Sumtype warning

2021-07-11 Thread JG via Digitalmars-d-learn
I am getting the following message: Warning: struct SumType has method toHash, however it cannot be called with const(SumType!(A,B,C)) this Could someone point in the right direction to understand what I am doing that causes this?