Re: Two major problems with dub

2021-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/1/21 11:38 AM, Alain De Vos wrote: Dub has two big problems. 1. Unmaintained dub stuff. 2. Let's say you need bindings to postgresql library and you will see dub pulling in numerous of libraries, which have nothing at all to do with postgresql. More like a framework stuff. This creates

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread user1234 via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:31:45 UTC, Rekel wrote: I recently found one can return function calls to void functions, though I don't remember any documentation mentioning this even though it doesn't seem trivial. [...] If this is intended, where could I find this in the docs? I haven't

Re: Find struct not passed by reference

2021-08-02 Thread jfondren via Digitalmars-d-learn
On Monday, 2 August 2021 at 23:06:42 UTC, frame wrote: Is there a way to find a struct which should be passed by reference but accidentally isn't? Maybe with copy constructors? @disable postblit: ```d struct NoCopy { int n; @disable this(this); } void modify(NoCopy nc) { nc.n++;

Find struct not passed by reference

2021-08-02 Thread frame via Digitalmars-d-learn
Is there a way to find a struct which should be passed by reference but accidentally isn't? Maybe with copy constructors?

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 02, 2021 at 04:42:14PM +, Rekel via Digitalmars-d-learn wrote: [...] > Also slightly off topic, but when would one use an alias instead of a > function/delegate? I haven't used aliases before. When you want a compile-time binding that could potentially elide the indirect function

compare types of functions.

2021-08-02 Thread vit via Digitalmars-d-learn
Hello, Why this doesn't work: ```d template DestructorType(T){ alias Get(T) = T; alias DestructorType = Get!(typeof((void*){ T tmp; })); } struct Foo{ ~this()@safe{} } ``` ```d void main(){ //Error: static assert: `is(void function(void*) pure nothrow

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread Ali Çehreli via Digitalmars-d-learn
On 8/2/21 9:42 AM, Rekel wrote: > when would one use an alias instead of a > function/delegate? I haven't used aliases before. alias will match both functions and delegates... and... any symbol at all. So, if you don't have a reason to constain the user, callable template parameters are most

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread Rekel via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:51:07 UTC, H. S. Teoh wrote: This is intentional, in order to make it easier to write generic code without always having to special-case functions that don't return anything. Ooh that indeed seems useful. Thanks for the hint. Also slightly off topic, but when

Re: cast to pure function stop work after upgrade

2021-08-02 Thread Tejas via Digitalmars-d-learn
On Monday, 2 August 2021 at 15:10:06 UTC, vit wrote: On Monday, 2 August 2021 at 11:28:46 UTC, Tejas wrote: [...] Try this: ```d void main(){ fp = cast(typeof(fp)) //fails } ``` Agh, stupid me. You the man!!

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread Rekel via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:46:36 UTC, jfondren wrote: C, C++, Rust, and Zig are all fine with this. Nim doesn't like it. I had no clue, never seen it used in any case. I've always assumed one couldn't return void as it's not a value. I guess intuitions aren't always universal . Good to

Re: cast to pure function stop work after upgrade

2021-08-02 Thread vit via Digitalmars-d-learn
On Monday, 14 June 2021 at 13:31:51 UTC, baby_tiger wrote: this used work for me, after upgrade I get this error. how to fix it ? import std.traits; enum LogLevel : ubyte { INFO = 0, WARN, ERROR,

Re: cast to pure function stop work after upgrade

2021-08-02 Thread vit via Digitalmars-d-learn
On Monday, 2 August 2021 at 11:28:46 UTC, Tejas wrote: On Monday, 14 June 2021 at 13:31:51 UTC, baby_tiger wrote: [...] It seems to not work at runtime either. Maybe they've made this behaviour illegal now? Hopefully someone answers. ```d import std.traits; import core.stdc.stdarg;

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 02, 2021 at 02:31:45PM +, Rekel via Digitalmars-d-learn wrote: > I recently found one can return function calls to void functions, > though I don't remember any documentation mentioning this even though > it doesn't seem trivial. This is intentional, in order to make it easier to

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread jfondren via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:31:45 UTC, Rekel wrote: I recently found one can return function calls to void functions, though I don't remember any documentation mentioning this even though it doesn't seem trivial. ```d void print(){ writeln("0"); } void doSomething(int a){

Is returning void functions inside void functions a feature or an artifact?

2021-08-02 Thread Rekel via Digitalmars-d-learn
I recently found one can return function calls to void functions, though I don't remember any documentation mentioning this even though it doesn't seem trivial. ```d void print(){ writeln("0"); } void doSomething(int a){ if (a==0) return print();

Re: Registering-unregistering threads

2021-08-02 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 30 July 2021 at 23:48:41 UTC, solidstate1991 wrote: Info on it is quite scarce and a bit confusing. If I unregister from the RT, will that mean it'll be GC independent, or will have other consequences too? The consequence is that the stack memory of that thread isn't traced, so

Re: cast to pure function stop work after upgrade

2021-08-02 Thread Tejas via Digitalmars-d-learn
On Monday, 14 June 2021 at 13:31:51 UTC, baby_tiger wrote: this used work for me, after upgrade I get this error. how to fix it ? import std.traits; enum LogLevel : ubyte { INFO = 0, WARN, ERROR,

Re: translate C struct char array into D

2021-08-02 Thread workman via Digitalmars-d-learn
On Friday, 30 July 2021 at 21:53:48 UTC, russhy wrote: On Friday, 30 July 2021 at 14:05:58 UTC, workman wrote: I get want to define this struct in D: ```c struct test1 { struct test1 *prev; struct test1 *next; size_t v1; size_t v2; size_t v3; char data[]; }; ``` ```d

Re: Registering-unregistering threads

2021-08-02 Thread user1234 via Digitalmars-d-learn
On Friday, 30 July 2021 at 23:48:41 UTC, solidstate1991 wrote: I'm doing some audio-related work, and one thing I need is to unregister from (and maybe later temporarily re-register to) the GC, since it would cause some issues, GC + audio is only a problem if its pauses (e.g in the audio