Re: What are (were) the most difficult parts of D?

2022-05-15 Thread max haughton via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali Learning D is almost a complete blur in my memory but I distinctly

Re: Why are structs and classes so different?

2022-05-15 Thread Tejas via Digitalmars-d-learn
On Sunday, 15 May 2022 at 21:33:24 UTC, Ali Çehreli wrote: D programmers don't write move constructors or move assignment. Such concepts don't even exist. Never say never : https://github.com/dlang/DIPs/blob/master/DIPs/DIP1040.md Walter is one of the authors of the DIP Also, there's

Re: What are (were) the most difficult parts of D?

2022-05-15 Thread cc via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali Immutability. Ended up having to do so many hundreds of casts to

Re: Why are structs and classes so different?

2022-05-15 Thread Walter Bright via Digitalmars-d-learn
On 5/15/2022 8:26 AM, Kevin Bailey wrote: I'm trying to understand why it is this way. Great question. The difference, in a nutshell, is a struct is a value type, and a class is a reference type. This difference permeates every facet their behavior. In C++, a struct can designed to be a

Re: Why are structs and classes so different?

2022-05-15 Thread forkit via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:26:40 UTC, Kevin Bailey wrote: I've done some scripting in D over the years but I never dug into D until recently. I'm going through Learning D and I was reminded that structs and classes are so different. - struct methods are non-virtual while class methods are

Re: Why are structs and classes so different?

2022-05-15 Thread forkit via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:59:17 UTC, Alain De Vos wrote: Can i summarize , structs are value-objects which live on the stack. class instances are reference objects which live on the heap. the real difference, is that structs, being value types, are passed by value, and classes, being

Re: Why are structs and classes so different?

2022-05-15 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, May 15, 2022 at 08:05:05PM +, Kevin Bailey via Digitalmars-d-learn wrote: [...] > But I asked a different question: Why can't I put a class object on > the stack? What's the danger? [...] You can. Use core.lifetime.emplace. Though even there, there's the theoretical problem of stack

Re: Why are structs and classes so different?

2022-05-15 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/22 13:05, Kevin Bailey wrote: > I've been programming in C++ full time for 32 years Hi from an ex-C++'er. :) I managed to become at least a junior expert in C++ between 1996-2015. I don't use C++ since then. I still think my answer is the real one. My implied question remains: Why

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 20:05:05 UTC, Kevin Bailey wrote: One question is, how should we pass objects - by value or by reference? In C++, you can do either, of course, but you take your chances if you pass by value - both in safety AND PERFORMANCE. The bottom line is that no one passes by

Re: Why are structs and classes so different?

2022-05-15 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Sunday, 15 May 2022 at 20:05:05 UTC, Kevin Bailey wrote: I've been programming in C++ full time for 32 years, so I'm familiar with slicing. It doesn't look to me like there's a concern here. Yes, slicing is not the issue. Slicing is a problem if you do "assignments" through a reference

Re: Why doesn't this piece of code work?

2022-05-15 Thread kdevel via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:27:32 UTC, SvGaming wrote: [...] It works if that code is the main function. But in the full program that is only one of the functions and is not the main function. Until you post your full programm ideally in a reduced form [1] everybody who is willing to help

Re: Why are structs and classes so different?

2022-05-15 Thread Kevin Bailey via Digitalmars-d-learn
Hi Mike (and Guillaume, since you posted the same link), Thanks for the long explanation. I've been programming in C++ full time for 32 years, so I'm familiar with slicing. It doesn't look to me like there's a concern here. There seem to be a couple different questions here. I suspect that

Re: FTP LS

2022-05-15 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 May 2022 at 19:13:10 UTC, ikod wrote: Added LIST command in v2.0.8 Thanks!

Re: FTP LS

2022-05-15 Thread ikod via Digitalmars-d-learn
On Saturday, 14 May 2022 at 08:42:46 UTC, Anonymouse wrote: Before I go on duplicating effort, does anyone have anything that can access FTP beyond PUT and GET? I need to read file information from a NAS so I know if I should upload a file or not. `dlang-requests` has `Request.post` and

Re: Why doesn't this piece of code work?

2022-05-15 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/22 08:27, SvGaming wrote: > I am so confused right now. It works if that code is the main function. > But in the full program that is only one of the functions and is not the > main function. Could it be that the main() function exits before calling that other function? You can

Re: Why are structs and classes so different?

2022-05-15 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/22 08:26, Kevin Bailey wrote: > structs and classes are so different. I think a more fundamental question is why structs and classes both exist at all. If they could be the same, one kind would be sufficient. And the answer is there are value types and there are reference types in

Re: Why are structs and classes so different?

2022-05-15 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:26:40 UTC, Kevin Bailey wrote: I'm trying to understand why it is this way. I assume that there's some benefit for designing it this way. I'm hoping that it's not simply accidental, historical or easier for the compiler writer. There's a problem that arises with

Re: Why are structs and classes so different?

2022-05-15 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:26:40 UTC, Kevin Bailey wrote: I'm trying to understand why it is this way. I assume that there's some benefit for designing it this way. I'm hoping that it's not simply accidental, historical or easier for the compiler writer. Perhaps someone more informed will

Re: Why are structs and classes so different?

2022-05-15 Thread Alain De Vos via Digitalmars-d-learn
Can i summarize , structs are value-objects which live on the stack. class instances are reference objects which live on the heap.

Re: Why doesn't this piece of code work?

2022-05-15 Thread SvGaming via Digitalmars-d-learn
On Sunday, 15 May 2022 at 12:27:45 UTC, kdevel wrote: On Sunday, 15 May 2022 at 12:19:22 UTC, SvGaming wrote: [...] [...] Install the `strace` program (I assume you are running Linux) and start your program under strace: [...] I am so confused right now. It works if that code is the main

Why are structs and classes so different?

2022-05-15 Thread Kevin Bailey via Digitalmars-d-learn
I've done some scripting in D over the years but I never dug into D until recently. I'm going through Learning D and I was reminded that structs and classes are so different. - struct methods are non-virtual while class methods are virtual - Thus, structs can't inherit, because how would you

decimal type in d

2022-05-15 Thread vit via Digitalmars-d-learn
Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed in sql DB. Something like C# decimal. Exists this kind of library ind D? (ideally `pure @safe @nogc

Re: Why doesn't this piece of code work?

2022-05-15 Thread kdevel via Digitalmars-d-learn
On Sunday, 15 May 2022 at 12:19:22 UTC, SvGaming wrote: [...] This code runs as expected. Strange. It does not for me. I even tried different compilers. It simply does not ask for user input here where it is supposed to: ```d writef("Type the path to your USB drive: "); string cont = readln;

Re: Why doesn't this piece of code work?

2022-05-15 Thread SvGaming via Digitalmars-d-learn
On Sunday, 15 May 2022 at 12:13:14 UTC, kdevel wrote: On Sunday, 15 May 2022 at 11:10:41 UTC, SvGaming wrote: [...] ``` import std.stdio; import std.process; int main () { writeln("Here is a list of your mounted drives: "); auto mounts = executeShell("cat /proc/mounts | grep media");

Re: Why doesn't this piece of code work?

2022-05-15 Thread SvGaming via Digitalmars-d-learn
On Sunday, 15 May 2022 at 11:10:41 UTC, SvGaming wrote: I want to ask the user to select their USB drive by typing the mount location. For some reason that does not work and just skips over the user input part. ```d void writeusb() { writeln("Here is a list of your mounted drives: ");

Re: Why doesn't this piece of code work?

2022-05-15 Thread kdevel via Digitalmars-d-learn
On Sunday, 15 May 2022 at 11:10:41 UTC, SvGaming wrote: I want to ask the user to select their USB drive by typing the mount location. For some reason that does not work and just skips over the user input part. ```d void writeusb() { writeln("Here is a list of your mounted drives: ");

Why doesn't this piece of code work?

2022-05-15 Thread SvGaming via Digitalmars-d-learn
I want to ask the user to select their USB drive by typing the mount location. For some reason that does not work and just skips over the user input part. ```d void writeusb() { writeln("Here is a list of your mounted drives: "); auto mounts = executeShell("cat /proc/mounts |