Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 13:35:19 UTC, matheus wrote: On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote: ... Similar posts that may help: https://forum.dlang.org/thread/hryadrwplyezihwag...@forum.dlang.org https://forum.dlang.org/thread/dblfikgnzqfmmglwd...@forum.dlang.org

Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 14:59:24 UTC, Kagamin wrote: 1) arena allocator makes memory manageable with occasional cache invalidation problem 2) no hashtable no problem 3) error handling depends on your code complexity, but even in complex C# code I found exceptions as boolean: you either have

Re: How to use D without the GC ?

2024-06-11 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer wrote: I would instead ask the reason for wanting to write D code without the GC. -Steve Hi Steve, Two reasons. 1. I am writting a dll to use in Python. So I am assuming that manual memory management is better for this project

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 01:35:26 UTC, monkyyy wrote: rather then worring about the gc, just have 95% of data on the stack How's that even possible ? AFAIK, we need heap allocated memory in order to make GUI lib as a DLL. So creating things in heap and modify it, that's the nature of m

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 09:44:05 UTC, DrDread wrote: also just slap @nogc on your main function to avoid accidential allocations. Thanks for the suggestion. Let me check that idea.

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 10:16:26 UTC, Sergey wrote: Btw are you going to use PyD or doing everything manually from scratch? Does PyD active now ? I didn't tested it. My approach is using "ctypes" library with my dll. Ctypes is the fastes FFI in my experience. I tested Cython, Pybind11

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 15:21:22 UTC, bachmeier wrote: You're splitting things into GC-allocated memory and manually managed memory. There's also SafeRefCounted, which handles the malloc and free for you. Thanks, I have read about the possibilities of "using malloc and free from D" in

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote: A SafeRefCounted example with main marked @nogc: Thanks for the sample. It looks tempting! Let me check that.

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 15:33:39 UTC, bachmeier wrote: A SafeRefCounted example with main marked @nogc: ``` import std; import core.stdc.stdlib; struct Foo { double[] data; double * ptr; alias data this; @nogc this(int n) { ptr = cast(double*) malloc(n*double.sizeof); dat

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 18:58:49 UTC, evilrat wrote: the only problem is that it seems to leak a lot PydObjects so i have to manually free them, even scope doesn't helps with that which is sad. Oh I see. I did some experiments with nimpy and pybind11. Both experiments were resulted in

Re: How to use D without the GC ?

2024-06-12 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 18:57:41 UTC, bachmeier wrote: Try `foo[10] = 1.5` and `foo.ptr[10] = 1.5`. The first correctly throws an out of bounds error. The second gives `Segmentation fault (core dumped)`. We can use it like this, i think. ``` struct Foo { double * ptr; uint capacity

Re: How to find the right function in the Phobos library?

2024-08-17 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 17 August 2024 at 17:31:53 UTC, Steven Schveighoffer wrote: Go to dlang.org, select dicumentation, then library reference. Pick any module, click on it In the upper right, switch the docs from stable to ddox Now you can use the search bar and it is interactive. Typing in indexOf

Re: How to find the right function in the Phobos library?

2024-08-18 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 17 August 2024 at 19:54:07 UTC, Richard (Rikki) Andrew Cattermole wrote: https://dlang.org/phobos/core_thread_osthread.html#.Thread.sleep Worth noting is that sleeping is not equivalent to performing work. It's the exact opposite, the lack of work. Thanks Rikki. Actually, I wa

Re: How to find the right function in the Phobos library?

2024-08-18 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 18 August 2024 at 08:39:49 UTC, IchorDev wrote: As Rikki points out, delay or sleep functions (as the name says) ‘put the thread to sleep’. If you want the thread to be constantly busy, you can use a while loop: ```d import core.time; //waste electricity for 1ms: const endTime = M

Re: I want to append to lists without using append

2022-04-04 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 4 April 2022 at 13:32:19 UTC, Steven Schveighoffer wrote: This looks more like lisp or scheme. You know this is a forum for the D programming language? This was the same question in my mind.

How to implement private constructor

2022-04-24 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, Please take a look at this code. Is this the right way to use private constructors ? ```d class Foo { int p1 ; string p2 ; bool p3 ; private this(int a, string b, bool c) { this.p1 = a this.p2 = b this.p3 = c } this(int a) { this(

Re: How to implement private constructor

2022-04-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 April 2022 at 02:22:42 UTC, Ali Çehreli wrote: Looks good to me. There are other ways as well: Thanks a lot. All I wanted to implement more than ctor with different parameters and avoid code duplication.

Re: How to implement private constructor

2022-04-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 April 2022 at 07:19:31 UTC, bauss wrote: Yes and in addition to Ali's message then remember it's private for the module only. Oops typo. What I meant is that private is module level, so it's __not__ private in the module, but it is for other modules. Thanks for the reply.

How to remove an element from a dynamic array with given index ?

2022-05-02 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I have dynamic array and I want to remove an element from it. All I have the index of the element to remove. And I want to the array should be in the same order. How to do it ?

Re: How to remove an element from a dynamic array with given index ?

2022-05-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 2 May 2022 at 20:50:17 UTC, H. S. Teoh wrote: should be in the same order. How to do it ? int[] data = [ 10, 20, 30, 40, 50 ]; data = data.remove(2); assert(data == [ 10, 20, 40, 50 ]); T Thanks a lot.

How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all. I want to convert an LPCWSTR to string. I have a struct like this ```cpp typedef struct tagNMDATETIMESTRINGW { NMHDR nmhdr; LPCWSTRpszUserString; SYSTEMTIME st; DWORD dwFlags; } NMDATETIMESTRINGW, *LPNMDATETIMESTRINGW; ``` I want to convert this `pszUserString` to a s

Re: How to convert a LPCWSTR aka const(wchar)* to string

2022-05-09 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 01:07:37 UTC, Mike Parker wrote: ```d import std.conv : to; string s = to!string(pszUserString); ``` Thanks, it worked. At first, I tried `to!string` but it failed because of this usage-- ```d this(LPCWSTR dtpStr) { this.dateString = to!string(LPCWSTR)(dtpStr) ; }

How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I want to call the Bitmap function from gdi+. This is the syntax of the function in C++. ```c++ void Bitmap( [in] const WCHAR *filename, [in] BOOLuseEmbeddedColorManagement ); ``` And this is the mangled name which I got from goldbolt compiler. `?Bitmap@@YAXPEB_WH@Z ` Now, t

Re: How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 5 June 2022 at 10:57:16 UTC, rikki cattermole wrote: Bitmap is a class, not a namespace. The function you want is actually a constructor. https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/gdiplus/gdiplusheaders.h#L179 Thank you for the reply. Well, I know t

Re: How to call a GDI+ function from D ?

2022-06-05 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 5 June 2022 at 11:33:14 UTC, Vinod K Chandran wrote: For future readers of this thread, rikki cattermole helped me to findthe solution to this problem. I Do not need the C++ classes or their methods for this. There is a set of C functions in gdiplus.dll. Check this link. https:/

Re: Window created with Windows API is not visible

2022-06-18 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 18 June 2022 at 21:03:23 UTC, solidstate1991 wrote: It seems that you are created a layered window. So chances are there to it become translucent.

Re: How to call a function from a dll created with d ?

2022-07-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 1 July 2022 at 20:08:45 UTC, ryuukk_ wrote: I think it is `extern(D) void testFunc();`? Thanks for the reply. But the result is same linker error.

Re: How to call a function from a dll created with d ?

2022-07-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 1 July 2022 at 21:02:20 UTC, mw wrote: I think the problem is the linker looking for dime.testFunc, while your lib function is dimedll.testFunc Thanks for the reply. What about this `mixin SimpleDllMain;` I suspect this.

Re: How to call a function from a dll created with d ?

2022-07-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 1 July 2022 at 22:22:42 UTC, mw wrote: Try follow instructions here: https://wiki.dlang.org/Win32_DLLs_in_D Thanks. So using a `def` file is a must I think. At first, I thought I can skip that.

Re: How to call a function from a dll created with d ?

2022-07-01 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 1 July 2022 at 22:38:17 UTC, Adam D Ruppe wrote: On Friday, 1 July 2022 at 22:32:24 UTC, Vinod K Chandran wrote: So using a `def` file is a must I think. no it is not. you just need to mark things export and make sure names match (including module name) Thanks for the reply. Thes

Re: How to call a function from a dll created with d ?

2022-07-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 2 July 2022 at 01:05:25 UTC, Ali Çehreli wrote: 3) The users of this dll should import that .di file (declaring the functions themselves won't work): Ali Hi, Thanks for the reply. I have tried your suggestion. First, I compiled my dll's source code with `-H` switch as you sai

Re: How to call a function from a dll created with d ?

2022-07-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 2 July 2022 at 21:36:50 UTC, mw wrote: Actually, can you create a github repo, I'm sure people will send you a working PR. Yes I can. I will inform here once I did it.

How to read live output from another process ?

2023-06-23 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am trying to create a program which burns time codes to a video. I am using ffmpeg for this. So far, I can successfully start ffmpeg in another thread and stop it when I need. But I can't read the live outputs from ffmpeg. This is my code. ```d void onBtnBurnClick(Control c, EventArg

Re: How to read live output from another process ?

2023-06-28 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 23 June 2023 at 23:37:29 UTC, Vinod K Chandran wrote: Hi all, Hi, I found the solution by myself. We can use Pipe struct for this job. Here is the code looks like. This is for future readers. ```d void onBtnBurnClick(Control c, EventArgs e) { // A button click event handler

How to use classes from another d files

2019-10-22 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am new to D. But some fair experience with vb.net. I was playing with D classes. I wrote a class in a D file. The file name is "classFile.d" ```D class TestClass { int myIntVar; string myStringVar ; this(int miv, string msv) { this.myIntVar = miv ;

Re: How to use classes from another d files

2019-10-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 17:40:11 UTC, Arun Chandrasekaran wrote: On Tuesday, 22 October 2019 at 17:34:51 UTC, Vinod K Chandran wrote: Hi all, I am new to D. But some fair experience with vb.net. I was playing with D classes. I wrote a class in a D file. The file name is "classFile.d" `

Re: How to use classes from another d files

2019-10-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 17:38:58 UTC, Adam D. Ruppe wrote: On Tuesday, 22 October 2019 at 17:34:51 UTC, Vinod K Chandran wrote: Hi all, I am new to D. But some fair experience with vb.net. I was playing with D classes. I wrote a class in a D file. The file name is "classFile.d" did y

Re: How to use classes from another d files

2019-10-24 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 18:33:32 UTC, Ali Çehreli wrote: On 10/22/2019 11:25 AM, Vinod K Chandran wrote: > On Tuesday, 22 October 2019 at 17:38:58 UTC, Adam D. Ruppe wrote: >> [...] Chandran wrote: >>> [...] playing >> [...] command line? That: The -i switch is the answer to your question

Re: How to use classes from another d files

2019-10-24 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 18:31:17 UTC, Adam D. Ruppe wrote: On Tuesday, 22 October 2019 at 18:21:36 UTC, Vinod K Chandran wrote: But what if there is too many include files ? The dmd -i thing will do that for you dmd -i main.d and it will automatically find the others, assuming they ar

Re: How to use classes from another d files

2019-10-24 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 18:34:52 UTC, Daniel Kozak wrote: On Tue, Oct 22, 2019 at 8:30 PM Vinod K Chandran via Digitalmars-d-learn wrote: On Tuesday, 22 October 2019 at 17:38:58 UTC, Adam D. Ruppe wrote: > On Tuesday, 22 October 2019 at 17:34:51 UTC, Vinod K > Chandran

Re: How to use classes from another d files

2019-10-24 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 24 October 2019 at 10:19:23 UTC, Vinod K Chandran wrote: On Tuesday, 22 October 2019 at 18:34:52 UTC, Daniel Kozak wrote: On Tue, Oct 22, 2019 at 8:30 PM Vinod K Chandran via Digitalmars-d-learn wrote: On Tuesday, 22 October 2019 at 17:38:58 UTC, Adam D. Ruppe wrote

Which is the active fork in DFL gui library ?

2019-11-02 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I just found that DFL gui library very interesting. But after some searching, i can see that DFL is inactive and there is few other forks for it. So this is my question - Which fork is good for a gui development in windows platform. BTW, i just tested the gtkD and successfully compiled

Re: Which is the active fork in DFL gui library ?

2019-11-03 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 3 November 2019 at 14:01:03 UTC, Jesse Phillips wrote: On Saturday, 2 November 2019 at 20:01:27 UTC, Vinod K Chandran wrote: Hi all, I just found that DFL gui library very interesting. But after some searching, i can see that DFL is inactive and there is few other forks for it. So t

Re: Which is the active fork in DFL gui library ?

2019-11-03 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 3 November 2019 at 07:07:42 UTC, Mike Parker wrote: On Sunday, 3 November 2019 at 07:06:12 UTC, Mike Parker wrote: Here's an example, winhello.d, that should work with all of the following command lines: Sorry, here's the example: == winhello.d /+ dub.sdl: name "entry" dflags

Alternative to C++ macro in D

2019-11-03 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I can do this in C++. #include using namespace std ; #define end }; #define log(x) cout << x << endl #define wait std::cin.get() int main() { log("Trying to avoid the visual clutter aused by closing curly braces") ; string myStr = "Now, code looks more elegant" ; log(myS

Re: Alternative to C++ macro in D

2019-11-03 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 3 November 2019 at 16:55:36 UTC, Vinod K Chandran wrote: Hi all, I can do this in C++. #include using namespace std ; #define end }; #define log(x) cout << x << endl #define wait std::cin.get() int main() { log("Trying to avoid the visual clutter aused by closing curly braces

Re: Which is the active fork in DFL gui library ?

2019-11-04 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 3 November 2019 at 23:25:40 UTC, Jesse Phillips wrote: On Sunday, 3 November 2019 at 16:48:52 UTC, Vinod K Chandran wrote: On Sunday, 3 November 2019 at 14:01:03 UTC, Jesse Phillips https://github.com/Rayerd/dfl @Jesse Phillips, Thank you for the reply. Does DWT is built upon Ja

Re: Which is the active fork in DFL gui library ?

2019-11-04 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 4 November 2019 at 19:29:22 UTC, Jacob Carlborg wrote: On 2019-11-03 17:48, Vinod K Chandran wrote: [...] Yes. It's a full translation of the Java code to D. No JNI, JVM or Java or remains. [...] I don't know if that's the case. Also I don't know if that's related to Java/JV

How to use "*.def" files in order to avoid cmd windows ?

2019-11-09 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am just playing with some win api code in D. Well, so far so good. I've create a simple program which shows a message box. I know i can avoid the cmd window with "dmd -L/SUBSYSTEM:windows". But this https://wiki.dlang.org/D_for_Win32 says that a "*.def" file with these two lines "EX

Re: Alternative to C++ macro in D

2019-11-09 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 4 November 2019 at 00:20:37 UTC, Ali Çehreli wrote: On 11/03/2019 08:55 AM, Vinod K Chandran wrote: > [...] There is nothing that stops one from using the C++ preprocessor on any text file. For example, you can do the following wherever GCC exists. If there are the following lines i

Re: How to use "*.def" files in order to avoid cmd windows ?

2019-11-09 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 10 November 2019 at 00:00:55 UTC, Adam D. Ruppe wrote: On Saturday, 9 November 2019 at 23:59:20 UTC, Vinod K Chandran wrote: I 'named the the def file "simple.def", since my programs name is also "simple". But no luck. Any help ? you need to pass the .def file on the dmd command li

How to import & export modules

2019-11-10 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am practicing D by writting a win API gui wrapper. I want to use a single module import to use this Gui lib. Say i have 10 modules like-- "App.d, Form.d, Button.d, Label.d, TextBox.d, ComboBox.d, ListBox.d, CheckBox.d, Panel.d, DateTimePicker.d" In Nim, i can import and export all the

How to import modules from another folder ?

2020-05-13 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am practicing some win32 api coding in D. So far so good. But when i tried to import some d files from another folder, i wonder how do this. This is my folder structure. --> Source Folder --> app.d //This is my main file. I am importing guiLib in this main file. -->

Re: How to import modules from another folder ?

2020-05-13 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 22:10:02 UTC, Vinod K Chandran wrote: Hi all, I am practicing some win32 api coding in D. So far so good. But when i tried to import some d files from another folder, i wonder how do this. This is my folder structure. --> Source Folder --> app.d //This is

DScanner warns class is undocumented, how to resolve it ?

2020-05-13 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I wrote a class and in VS Code, DScanner says that the class is undocumented. How can i document a class ?

Re: DScanner warns class is undocumented, how to resolve it ?

2020-05-13 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 06:05:00 UTC, Vinod K Chandran wrote: Hi all, I wrote a class and in VS Code, DScanner says that the class is undocumented. How can i document a class ? Never mind, i found the answer myself. Just like in dot net, i added triple forward slash comment and problem so

Re: DScanner warns class is undocumented, how to resolve it ?

2020-05-14 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 11:25:48 UTC, Cogitri wrote: On Thursday, 14 May 2020 at 06:08:17 UTC, Vinod K Chandran wrote: [...] Also see https://dlang.org/spec/ddoc.html for more info on DDoc. FWIW you can also disable the warning by adding the following to VSCode's settings.json: "dscann

Re: DScanner warns class is undocumented, how to resolve it ?

2020-05-14 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 08:02:28 UTC, Dennis wrote: On Thursday, 14 May 2020 at 06:08:17 UTC, Vinod K Chandran wrote: On Thursday, 14 May 2020 at 06:05:00 UTC, Vinod K Chandran wrote: Hi all, I wrote a class and in VS Code, DScanner says that the class is undocumented. How can i document a

How to include my own library in my d program with dub ?

2020-05-14 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I just build a skeleton of a Gui library(win32 based) for my own purpose. How do i use this in my d programs with dub ? Now, all files are located in a folder called "GuiLib". Side note : Why i started making a gui library instead of learning language ? Answer : By this way, i can learn

How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
Hi, For some unknown reasons, dub is not working for me. But i can build my program with "dmd -i". But i would like to know if there is any code to run my program with "dmd -i". Note : "rdmd" is also working but it creates the exe file in temp directory, so my AV is catching it every time. Its

Re: How to include my own library in my d program with dub ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 12:57:19 UTC, JN wrote: On Thursday, 14 May 2020 at 12:53:43 UTC, Vinod K Chandran wrote: Hi all, I just build a skeleton of a Gui library(win32 based) for my own purpose. How do i use this in my d programs with dub ? Now, all files are located in a folder called "G

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 15 May 2020 at 18:22:47 UTC, Seb wrote: On Friday, 15 May 2020 at 14:09:00 UTC, Vinod K Chandran wrote: Hi, For some unknown reasons, dub is not working for me. But i can build my program with "dmd -i". But i would like to know if there is any code to run my program with "dmd -i". N

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 15 May 2020 at 14:29:38 UTC, Adam D. Ruppe wrote: use the -run switch to dmd. Make sure it and te d file name are the LAST arguments. dmd -i other_dmd_args_you_need -run yourfile.d Thank you for the reply. Let me try. :)

How to get rid of "nothrow" ?

2020-05-17 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc function is a "nothrow" function, i cannot use any function withou

Re: How to get rid of "nothrow" ?

2020-05-17 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 17 May 2020 at 09:50:00 UTC, Olivier Pisano wrote: On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write so

Re: How to get rid of "nothrow" ?

2020-05-17 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 17 May 2020 at 14:21:41 UTC, Vinod K Chandran wrote: On Sunday, 17 May 2020 at 09:50:00 UTC, Olivier Pisano wrote: On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my wi

Re: How to get rid of "nothrow" ?

2020-05-18 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 17 May 2020 at 19:37:05 UTC, drug wrote: 17.05.2020 17:35, Vinod K Chandran пишет: It worked. Thanks :) I have one more question. Which is better, to include all the switch cases inside a single try catch or write separate try catch for each switch cases ? all the switch cases in

Re: DScanner warns class is undocumented, how to resolve it ?

2020-05-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 14 May 2020 at 08:02:28 UTC, Dennis wrote: On Thursday, 14 May 2020 at 06:08:17 UTC, Vinod K Chandran wrote: On Thursday, 14 May 2020 at 06:05:00 UTC, Vinod K Chandran wrote: Hi all, I wrote a class and in VS Code, DScanner says that the class is undocumented. How can i document a

Is it possible to write some class members in another module ?

2020-05-19 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, Is it possible to write some class members in another module ? I have class with a lot of member variables.(probably 50+) I would like to write them (Not all, but some of them) in a special module for the sake of maintenance.

Re: Is it possible to write some class members in another module ?

2020-05-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 22:10:25 UTC, Adam D. Ruppe wrote: On Tuesday, 19 May 2020 at 22:01:03 UTC, Vinod K Chandran wrote: Is it possible to write some class members in another module ? You can make some of members be other structs that you aggregate together. That's a good idea but the

Re: Is it possible to write some class members in another module ?

2020-05-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 23:51:45 UTC, Boris Carvajal wrote: On Tuesday, 19 May 2020 at 22:01:03 UTC, Vinod K Chandran wrote: Hi all, Is it possible to write some class members in another module ? I have class with a lot of member variables.(probably 50+) I would like to write them (Not all,

Re: Is it possible to write some class members in another module ?

2020-05-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 15:01:36 UTC, welkam wrote: On Wednesday, 20 May 2020 at 09:45:48 UTC, Vinod K Chandran wrote: // Now, we need to use like this auto form= new Window(); form.event.click = bla_bla; // I really want to use like this auto form= new Window(); form.click = bla_bla; ```

How to use this forum ?

2020-05-20 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I have some questions about this forum. 1. How to edit a post ? 2. How to edit a reply ? 3. How to add some code(mostly D code) in posts & replies. 4. How to add an image in posts & replies. 5. Is there a feature to mark my post as "[SOLVED]" ?

Re: How to use this forum ?

2020-05-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 21:06:35 UTC, welkam wrote: On Wednesday, 20 May 2020 at 20:49:52 UTC, Vinod K Chandran wrote: Hi all, I have some questions about this forum. 1. How to edit a post ? 2. How to edit a reply ? 3. How to add some code(mostly D code) in posts & replies. 4. How to add an

Re: How to use this forum ?

2020-05-21 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 21:13:25 UTC, Paul Backus wrote: On Wednesday, 20 May 2020 at 20:49:52 UTC, Vinod K Chandran wrote: [...] You can't. If you need to make a correction, the best you can do is to make a follow-up post. [...] Copy & paste it. [...] You can't embed images dir

Re: How to use this forum ?

2020-05-21 Thread Vinod K Chandran via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 21:15:25 UTC, Dukc wrote: On Wednesday, 20 May 2020 at 20:49:52 UTC, Vinod K Chandran wrote: [...] No can do :(. Well, moderators can delete posts so you could try to ask them nicely in some cases but the primary way tends to be the same as with email: send a corre

How to use GET_X_LPARAM in D ?

2020-05-21 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I need to use the macro GET_X_LPARAM. But compiler says that "undefined identifier GET_X_LPARAM". I cant find any modules with GET_X_LPARAM defined. Do i miss something ?

Re: How to use GET_X_LPARAM in D ?

2020-05-21 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 21 May 2020 at 18:42:47 UTC, Vinod K Chandran wrote: Hi all, I need to use the macro GET_X_LPARAM. But compiler says that "undefined identifier GET_X_LPARAM". I cant find any modules with GET_X_LPARAM defined. Do i miss something ? I search all modules in " C:\D\dmd2\src\druntim

Re: How to use GET_X_LPARAM in D ?

2020-05-21 Thread Vinod K Chandran via Digitalmars-d-learn
On Thursday, 21 May 2020 at 20:12:13 UTC, Harry Gillanders wrote: On Thursday, 21 May 2020 at 18:42:47 UTC, Vinod K Chandran wrote: Hi all, I need to use the macro GET_X_LPARAM. But compiler says that "undefined identifier GET_X_LPARAM". I cant find any modules with GET_X_LPARAM defined. Do i

How to use base class & child class as parameter in one function ?

2020-05-22 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I have a windows gui setup like this; class EventArgs {} \\ Base class for all messages class MouseEventArgs : EventArgs { // child class for handling mouse messages ... int x; int y; this(WPARAM wpm, LPARAM lpm){ this.x = xFromLparam(lpm); this.y = yF

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 12:21:25 UTC, rikki cattermole wrote: if (Child child = cast(Child)parent) { assert(child !is null); } Actually, problem occurs in addHandler function. It expects an argument of type "EventArgs", not MouseEventArgs.

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 16:12:12 UTC, Steven Schveighoffer wrote: On 5/22/20 9:10 AM, Vinod K Chandran wrote: On Friday, 22 May 2020 at 12:21:25 UTC, rikki cattermole wrote: if (Child child = cast(Child)parent) { assert(child !is null); } Actually, problem occurs in addHandler function.

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 20:06:20 UTC, Adam D. Ruppe wrote: On Friday, 22 May 2020 at 20:04:24 UTC, Vinod K Chandran wrote: sampleList.Add(New Child(10.5)) Is this possible in D without casting ? Direct translation of this code works just fine in D. Yeah, my bad. I just checked in D. But th

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 20:51:20 UTC, Steven Schveighoffer wrote: On 5/22/20 4:04 PM, Vinod K Chandran wrote: [...] Yes. What you cannot do is this (which I hope doesn't compile in VB.net, but I wouldn't be surprised): Dim sampleList As New List(Of Child) sampleList.Add(New Base(10)) Whi

Re: How to use base class & child class as parameter in one function ?

2020-05-23 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 22:44:17 UTC, H. S. Teoh wrote: On Fri, May 22, 2020 at 09:39:16PM +, Vinod K Chandran via Digitalmars-d-learn wrote: [...] So in the same manner, i want void function(Base) = fnPtr wiil work with void function(Child) You cannot, because that's type u

Re: How to use base class & child class as parameter in one function ?

2020-05-23 Thread Vinod K Chandran via Digitalmars-d-learn
On Friday, 22 May 2020 at 22:40:50 UTC, Steven Schveighoffer wrote: On 5/22/20 5:39 PM, Vinod K Chandran wrote: [...] That is the opposite of what you are thinking. A function pointer has to be valid based on its parameter types. Covariant functions are allowed. This is OK: void function(

How to get the pointer of "this" ?

2020-05-24 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I have a class like this. class Button : Control { ... HWND createButton(){ ... SetWindowSubclass(this.mHandle, SUBCLASSPROC(&btnWndProc), UINT_PTR(subClsID), cast(DWORD_PTR) this); } } But compiler says that - "Error: 'this' is not an lvalue an

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: [...] I think your issue might be elsewhere because casting this should be fine and it should not complain about that in your given code. At least you should be able to pass

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: [...] The error has nothing to do with taking a pointer to `this`. It's suggesting that somewhere in your code you're attempting to use the `this` reference like an lva

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 18:42:33 UTC, bauss wrote: On Monday, 25 May 2020 at 17:14:13 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: [...] Hi @Mike Parker, Thank you for your valuable suggestions. I will sure follow them. Well, the exact line numbe

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: cast(DWORD_PTR) this); Where is DWORD_PTR defined? I cant find it in docs. If its an alias of long then you have to cast to a pointer like this cast(long*) this; you need to

Re: How to get the pointer of "this" ?

2020-05-25 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:04:28 UTC, Adam D. Ruppe wrote: On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: Where is DWORD_PTR defined? it is a win32 thing. should be able to directly cast to it most the time if there is opCast on the class it needs another layer of helper function

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:54:32 UTC, Adam D. Ruppe wrote: On Monday, 25 May 2020 at 22:31:00 UTC, Vinod K Chandran wrote: A dword is an unsigned, 32-bit unit of data. We can use uint in D. I have tried that too, but no luck. A DWORD_PTR is *not* the same as a uint. It is more like a size_t

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 18:42:33 UTC, bauss wrote: On Monday, 25 May 2020 at 17:14:13 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: [...] Hi @Mike Parker, Thank you for your valuable suggestions. I will sure follow them. Well, the exact line numbe

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to the object and not a pointer like in C++. So I think that writing &this might be what you need? No. A class reference is a pointer

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to: SetWindowSubclass(this.mHandle, SUBCLASSPROC(&btnWndProc), UINT_PTR(subClsI

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 12:08:29 UTC, Johannes Loher wrote: On Tuesday, 26 May 2020 at 11:44:58 UTC, Vinod K Chandran wrote: [...] [...] It doesn't compile, the line string mt [...] Hi, Sorry for the typos in my code.

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 13:37:22 UTC, Vinod K Chandran wrote: On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to: SetWindowS

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 13:44:24 UTC, Adam D. Ruppe wrote: On Tuesday, 26 May 2020 at 11:35:23 UTC, Vinod K Chandran wrote: Okay, but uint is working perfectly. It won't if you use -m64. Okay. I got it.

Re: How to get the pointer of "this" ?

2020-05-26 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 13:48:52 UTC, ag0aep6g wrote: On 26.05.20 15:43, Vinod K Chandran wrote: So far now, two solutions are very clear for this problem. 1. As per John Chapman's suggestion - use cast(DWORD_PTR)cast(void*)this). 2. Use another varibale to use as an lvalue. - Button

  1   2   >