Re: guard clause style static if

2018-07-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/18 7:28 AM, kdevel wrote: It appears not to be possible to use static if in "guard clause style" as in    void bar (T ...) (T args)    {   static if (args.length == 0) return;   writeln (args [0]);   return bar (args [1 .. $]);    } Is this intended? Yes.

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread Alex via Digitalmars-d-learn
On Monday, 9 July 2018 at 17:26:30 UTC, vino.B wrote: Request Help: void process(alias coRoutine, T...)(Array!string Dirlst, T params) { ReturnType!coRoutine rData; / This line is not working alias scRType = typeof(coRoutine(string.init, T.init)); auto PFresult =

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread vino.B via Digitalmars-d-learn
On Monday, 9 July 2018 at 15:49:50 UTC, Alex wrote: On Monday, 9 July 2018 at 15:40:53 UTC, vino.B wrote: On Sunday, 8 July 2018 at 19:10:24 UTC, Alex wrote: On Sunday, 8 July 2018 at 18:46:31 UTC, vino.B wrote: Request you help, in the below code we pass the function "Testfun" as a

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Andre Pany via Digitalmars-d-learn
On Monday, 9 July 2018 at 13:48:05 UTC, Kagamin wrote: Correct signature: extern(C) void GetParamNames(const(char)** paramNames, size_t numParams); In C const applies only to the nearest member. Thank you, that looks great. Kind regards Andre

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread Alex via Digitalmars-d-learn
On Monday, 9 July 2018 at 15:40:53 UTC, vino.B wrote: On Sunday, 8 July 2018 at 19:10:24 UTC, Alex wrote: On Sunday, 8 July 2018 at 18:46:31 UTC, vino.B wrote: Request you help, in the below code we pass the function "Testfun" as a parameter to another function "process" in order for the

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread vino.B via Digitalmars-d-learn
On Sunday, 8 July 2018 at 19:10:24 UTC, Alex wrote: On Sunday, 8 July 2018 at 18:46:31 UTC, vino.B wrote: Request you help, in the below code we pass the function "Testfun" as a parameter to another function "process" in order for the function "process" to work we have to specify the type of

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Kagamin via Digitalmars-d-learn
Correct signature: extern(C) void GetParamNames(const(char)** paramNames, size_t numParams); In C const applies only to the nearest member.

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Kagamin via Digitalmars-d-learn
const(char)*[] znames; znames.length=4; GetParamNames(znames.ptr, znames.length); const char[][] names=znames.map!fromStringz.array;

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Andre Pany via Digitalmars-d-learn
On Monday, 9 July 2018 at 11:39:46 UTC, Basile B. wrote: Ok, i've read your other answers and it seems that you have a way to test so i think you'll figure it out yourself, but you don't need to alloc. Once the fromStringz verified to be good maybe dup/idup in case the C lib free the stuff

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 11:10:01 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:56:18 UTC, Andre Pany wrote: On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:56:18 UTC, Andre Pany wrote: On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be extern(C) void GetParamNames(const char** paramNames,

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Andre Pany via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:56:18 UTC, Andre Pany wrote: On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be extern(C) void GetParamNames(const char** paramNames,

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Andre Pany via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:38:54 UTC, Basile B. wrote: On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, no it's not correct i think, right translation would be extern(C) void GetParamNames(const char** paramNames, size_t numParams); If you use the D array syntax you'll get

Re: DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 9 July 2018 at 10:33:03 UTC, Andre Pany wrote: Hi, I need to call a C function within a DLL which has following signature: void GetParamNames (const char *paramNames[], size_t numParams); The purpose of this function is to return a list of texts I defined in D: extern(C)

DLL: (const char *paramNames[],size_t numParams)

2018-07-09 Thread Andre Pany via Digitalmars-d-learn
Hi, I need to call a C function within a DLL which has following signature: void GetParamNames (const char *paramNames[], size_t numParams); The purpose of this function is to return a list of texts I defined in D: extern(C) GetParamNames (const char[]* paramNames, size_t numParams); Is

Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
On Monday, 9 July 2018 at 09:38:30 UTC, ag0aep6g wrote: The `win` you're creating in `init` is a function-local variable. It ceases to exist when `init` returns. It's not `this.win`. In `run`, you're accessing `this.win`. It's still null because you never assigned anything there. So change

Re: class that is initialized becomes null when outside of function

2018-07-09 Thread ag0aep6g via Digitalmars-d-learn
On 07/09/2018 11:18 AM, Flaze07 wrote: class Game { [...]     RenderWindow win; [...]     void init()     { [...]     auto win = new RenderWindow( VideoMode( 600, 600 ), "snake" ); [...]     }     void run()     { [...]     writeln( win is null ); [...]     } } the

Re: class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
On Monday, 9 July 2018 at 09:18:50 UTC, Flaze07 wrote: I am using DSFML module game; [...] oh, and I forgot, I had Game myGame; static this() { myGame = new Game; } below the Game class

class that is initialized becomes null when outside of function

2018-07-09 Thread Flaze07 via Digitalmars-d-learn
I am using DSFML module game; import core.time; import std.stdio: writeln; import dsfml.graphics; import dsfgui.button; import apple; import snake; class Game { private: enum State { menu, playing } State state; Font font; Button playBtn; Snake snake; Apple apple;

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread Timoses via Digitalmars-d-learn
On Monday, 9 July 2018 at 05:54:27 UTC, vino.B wrote: On Sunday, 8 July 2018 at 19:22:32 UTC, Timoses wrote: Perhaps you could tell us what your goal is. People here might come up with a nice solution. Why do you feel like having to use templated functions in the first place? That is, what is

Re: Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

2018-07-09 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 9 July 2018 at 05:54:27 UTC, vino.B wrote: In phase 2 we are transferring few more function to the existing D code, and these functions has variable number of parameter and different type eg: Function3(string, string, string), Function(string, int, string, int). Initially I

Re: Memory corruption with COM object

2018-07-09 Thread Kagamin via Digitalmars-d-learn
You can enable logging in GC and see what's allocated and collected.