Re: Static struct initialization syntax behavior & it being disabled upon adding a constructor

2022-04-18 Thread zjh via Digitalmars-d-learn
On Sunday, 17 April 2022 at 15:13:29 UTC, HuskyNator wrote: This is a twofold question, along the example code below: The `default constructor` of `struct` is very convenient to use. I hope that d can support it like `C++`.

Re: Static struct initialization syntax behavior & it being disabled upon adding a constructor

2022-04-18 Thread zjh via Digitalmars-d-learn
On Monday, 18 April 2022 at 13:21:44 UTC, zjh wrote: I hope that d can support it like `C++`. `Struct` and `class` behavior is inconsistent. `Constructors` sometimes have initialize behavior. If D doesn't think about `C++` users, `C++` users feel too troublesome, can't understand, and the co

How to unpack template parameters,Or how to forward parameters?

2022-05-05 Thread zjh via Digitalmars-d-learn
Hello everyone,I have following function: ```d import core.stdc.stdio; void f(int i,int j){ printf("%i,%i",i,j); } ``` I want to forward `int[N]` to `(int i,int j)` etc. How can I write a forwarding function? ```d void ff(alias g,int...I)(int[2]k){ g(k[I]); }//How to unpack template vari

Re: How to unpack template parameters,Or how to forward parameters?

2022-05-05 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 05:44:39 UTC, vit wrote: Try this: Very Good,Thank you very much!

Re: Google Code Jam 2022

2022-05-06 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 04:26:13 UTC, Siarhei Siamashka wrote: Rust is happily eating D's lunch. Yes, `Rust` has intercepted d's most users. However, a good meal is not afraid of late . `Make up` the language and compete with them.

Re: Google Code Jam 2022

2022-05-06 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 06:57:40 UTC, zjh wrote: Yes, `Rust` has intercepted d's most users. `C++, Rust and python` all have the `biggest feature`, that is, they pay attention not only to the `language`, but also to the `library`! `D` language should be the `same`! For example, I think `d`

Re: Google Code Jam 2022

2022-05-06 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 06:57:40 UTC, zjh wrote: We should even `track` the `main libraries` of `major languages` and have `professionals` write their `ports` to `D`. There should also be `news` about `major language/major libraries`'s `major news or actions`.Instead of just `focusing on` o

Re: Google Code Jam 2022

2022-05-06 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 07:13:06 UTC, zjh wrote: In addition, `D` should not be positioned as `one`'s `second language`, but as `first language`. We should position ourselves in `comfort` and make programmers `feel good`. Only when the "`programmers`" are comfortable, naturally, they will c

Re: Google Code Jam 2022

2022-05-06 Thread zjh via Digitalmars-d-learn
On Friday, 6 May 2022 at 08:25:34 UTC, Siarhei Siamashka wrote: On Friday, 6 May 2022 at 07:05:35 UTC, zjh wrote: For example, I think `d` can also make use of `'winrt'`, which is very important for `GUI` programming . `D` officials should pay attention to `it`. I have downloaded `dwinrt` and

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

2022-05-11 Thread zjh 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. I don't know the progress of `interface to C++`. I want to use my C++ functions in `d`. `C++`'s `concept` and `...` is very convenient.

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

2022-05-11 Thread zjh via Digitalmars-d-learn
On Thursday, 12 May 2022 at 02:35:50 UTC, zjh wrote: `C++`'s `concept` and `...` is very convenient. And C++'s `stackless coroutine`.

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

2022-05-11 Thread zjh via Digitalmars-d-learn
On Thursday, 12 May 2022 at 02:40:09 UTC, zjh wrote: And C++'s `stackless coroutine`. Another one, I hope the `error message` can be adapted to different languages like `chinese/german/russion/turkish` etc.

Re: Exercises

2022-05-12 Thread zjh via Digitalmars-d-learn
On Thursday, 12 May 2022 at 13:04:51 UTC, Alain De Vos wrote: Is there a link to a webpage with some dlang exercises in order to see if i master the language, from simple to diffucult ? [dtour](https://tour.dlang.org/).

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

2022-05-12 Thread zjh via Digitalmars-d-learn
On Thursday, 12 May 2022 at 20:49:08 UTC, Chris Katko wrote: In D, I can do the module based method, but nothing short of renaming variables gives me a list of violations and, that also makes all the correct internal accesses wrong. Because private doesn't work. Call it whatever keyword you

Re: Back to Basics at DConf?

2022-05-13 Thread zjh via Digitalmars-d-learn
On Thursday, 12 May 2022 at 21:58:33 UTC, Ali Çehreli wrote: so what exact topic would you like to see? May be you can talk about how to link `d` to`C++`. There are too few examples. Or `D` how to link to `Rust`,etc. I don't even read the `basics` of C++, which is boring. And interested in

Re: Template shenannigans with multiple datatypes

2022-05-13 Thread zjh via Digitalmars-d-learn
On Friday, 13 May 2022 at 08:28:56 UTC, vit wrote: ... ```d ... this(DataSources dataSources){ this.dataSources = dataSources; } ... return new MultiGraph!(staticMap!(PointerTarget, Ts))(ts);//ts ``` How is `ts` convert to `DataSources`?

Re: Template shenannigans with multiple datatypes

2022-05-13 Thread zjh via Digitalmars-d-learn
On Friday, 13 May 2022 at 13:06:32 UTC, vit wrote: On Friday, 13 May 2022 at 11:58:15 UTC, zjh wrote: Thank you for your detail explain.

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

2022-05-13 Thread zjh via Digitalmars-d-learn
On Friday, 13 May 2022 at 21:54:04 UTC, max haughton wrote: I have a PR which alters the error message you get if you do ```d void main() { func() == 43; } ``` This is an example of an error message which could be counterintuitive to a new D programmer, Can `D` support error messages in `

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

2022-05-13 Thread zjh via Digitalmars-d-learn
On Friday, 13 May 2022 at 21:54:04 UTC, max haughton wrote: Can `D` support error messages in `multiple languages`? Such as `Chinese/German/Russian/Turkey`.

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

2022-05-13 Thread zjh via Digitalmars-d-learn
On Saturday, 14 May 2022 at 04:09:00 UTC, Ali Çehreli wrote: stopped by a spam filter. Right. D forum should add a "`author delete`" function. Likewise, each post could add something like `votes` , good posts will naturally `come out` and be collected together. It's really convenient for b

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

2022-05-13 Thread zjh via Digitalmars-d-learn
On Saturday, 14 May 2022 at 04:31:48 UTC, zjh wrote: Likewise, each post could add something like `votes` , Or something like all kinds of `tags` such as `range/fiber/commandline/auto ref/in/...`. Making `good use` of the `existing answers` in the forum will be very beneficial for `D` begi

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

2022-05-14 Thread zjh via Digitalmars-d-learn
On Saturday, 14 May 2022 at 08:51:24 UTC, H. S. Teoh wrote: The D wiki could be used for this purpose. Many of your posts are very good. I like them very much. Thank you. I haven't played with `wiki`. However, Maybe we can `organize and display` good posts according to `"author/category/la

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

2022-05-14 Thread zjh via Digitalmars-d-learn
On Saturday, 14 May 2022 at 12:46:45 UTC, frame wrote: Every larger app with a news feed also has possibility to categorize/filter it. I think we can set up a special `web page` to collect `good posts` and classify them according to `'author/category/label'`, and its content can be extracted

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

2022-05-17 Thread zjh via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 06:28:10 UTC, cc wrote: Far better to just keep your house clean every day than let the trash pile up and wait for the maid to come, IMO. Right,GC is a bad idea!

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

2022-05-17 Thread zjh via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:50:30 UTC, zjh wrote: Right,GC is a bad idea! Endless use of memory without freeing. It's totally unreasonable waste.

Re: UI Library

2022-05-20 Thread zjh via Digitalmars-d-learn
On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote: `winrt` may be good. but `winrtd` has many bugs.

Re: Why is the compiled file size so huge?

2022-05-28 Thread zjh via Digitalmars-d-learn
On Friday, 27 May 2022 at 13:40:25 UTC, Alexander Zhirov wrote: I'm trying to compile a file that weighs 3 kilobytes. I'm also linking a self-written dynamic library. I don't understand why the resulting executable file is so huge? I just switched from `32-bit` to 64 bit, but the '64' bit pro

Re: How do I initialize a templated constructor?

2022-08-08 Thread zjh via Digitalmars-d-learn
On Monday, 8 August 2022 at 12:26:50 UTC, rempas wrote: On Monday, 8 August 2022 at 11:03:21 UTC, Dom Disc wrote: You should first describe what you want to do clearly.

Re: Code compiles and run fine with LDC but segfault with DMD

2022-08-29 Thread zjh via Digitalmars-d-learn
On Monday, 29 August 2022 at 21:46:48 UTC, ryuukk_ wrote: What `-g` does that makes this code compile and work with DMD? I guess it's global sharing. not `tls`.

Re: Best practice for dub registry package and module names

2022-09-03 Thread zjh via Digitalmars-d-learn
On Sunday, 4 September 2022 at 01:52:11 UTC, Ali Çehreli wrote: Let's say I have three modules that work together, which I want to register on dub: A, B, and C. You should learn `ARSD`, and become `Ali-official`.

Re: importC and cmake

2022-09-06 Thread zjh via Digitalmars-d-learn
On Tuesday, 6 September 2022 at 19:44:23 UTC, jmh530 wrote: . `xmake` is simpler.

Re: Can you access the same classes from C++ and D and vise versa, or do the classes have to not form dependency cycle?

2022-09-10 Thread zjh via Digitalmars-d-learn
On Saturday, 10 September 2022 at 22:07:32 UTC, Ali Çehreli wrote: On 9/10/22 13:04, Daniel Donnell wrote: > https://dlang.org/spec/cpp_interface.html At DConf, Manu indicated that that page is outdated and that D's C++ support is actually a lot better. Update it quickly, This is a big selli

Re: importC and cmake

2022-09-27 Thread zjh via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 05:29:41 UTC, Chris Piker wrote: `Xmake` is indeed simpler. `Xmake` is really nice!

Re: importC and cmake

2022-09-29 Thread zjh via Digitalmars-d-learn
On Thursday, 29 September 2022 at 20:56:50 UTC, Chris Piker wrote: ```lua set_languages("c99") ``` Try: `add_cxflags` or `add_files("src/*.c")` or `set_languages("c")` or `set_languages("c11")` . or ,use `-l` to set language. ```cpp xmake create -l c -t static test ```

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread zjh via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 04:59:40 UTC, mw wrote: ... Why can't do it `in one step`? Why always afraid to `add features`? C++ is `so complicated` ,but that people are not afraid to continue to `add features`.

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread zjh via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 05:41:26 UTC, zjh wrote: Why can't do it `in one step`? Why always afraid to `add features`? C++ is `so complicated` ,but that people are not afraid to continue to `add features`. There is also `class level private`. I saw someone start it by himself, and he

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread zjh via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 05:50:18 UTC, zjh wrote: In my opinion, as long as `users` have reasonable needs, languages should added corresponding features, instead of becoming religions. `Some features` are very popular for users,I really don't know why they didn't add it. When you

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread zjh via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 05:41:26 UTC, zjh wrote: Why always afraid to `add features`? C++ is `so complicated` ,but that people are not afraid to continue to `add features`. Look at the `emerging` languages, which are not crazy about `adding features`. Even `go` is adding generics.

Re: My new programming book ...

2022-11-06 Thread zjh via Digitalmars-d-learn
On Sunday, 6 November 2022 at 22:43:33 UTC, ikelaiah wrote: Hi, ... Is there a second edition? After all, it has been many years.

Re: My new programming book ...

2022-11-06 Thread zjh via Digitalmars-d-learn
On Monday, 7 November 2022 at 04:54:05 UTC, ikelaiah wrote: ... Yes, more than 100 skills, not easy get.

Re: My new programming book ...

2022-11-06 Thread zjh via Digitalmars-d-learn
On Monday, 7 November 2022 at 01:06:23 UTC, Adam D Ruppe wrote: No, but not that much has changed and you can always post here with questions. How is your `minigui`? Please write an `introduction` when you have time.

Re: My new programming book ...

2022-11-08 Thread zjh via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 13:55:44 UTC, Adam D Ruppe wrote: It is on my list but minigui is a pretty simple class collection of basic widgets. It works pretty well now. I don't have too many intro examples yet though. My blog has one thing but it uses an experimental piece (http://dpldoc

Re: Hipreme's #5 Tip of the day - Avoid raw pointers at all cost

2022-11-11 Thread zjh via Digitalmars-d-learn
On Friday, 11 November 2022 at 13:05:19 UTC, Hipreme wrote: ... Nice article,thank you.

Re: How do you return a subclass instance from a base class method?

2022-11-16 Thread zjh via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:25:13 UTC, Daniel Donnelly, Jr. wrote: ... `crtp`, will it work?

Re: pragma(linkerDirective,_) removes double quotes, dmd ignores LIB

2022-11-28 Thread zjh via Digitalmars-d-learn
On Monday, 28 November 2022 at 16:21:20 UTC, NonNull wrote: Any idea what may be going on with dmd? use `sc.ini` like this: ```d [Version] version=7.51 Build 020 [Environment] lj=E:\path DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import" "-I%lj%\dimport" LIB="%@P%\..\lib"

Re: pragma(linkerDirective,_) removes double quotes, dmd ignores LIB

2022-11-28 Thread zjh via Digitalmars-d-learn
On Tuesday, 29 November 2022 at 01:08:03 UTC, zjh wrote: ... ```d [Environment64] LIB=%@P%\..\lib;%lj%\dku; ```

Re: How do I _really_ implement opApply?

2022-11-29 Thread zjh via Digitalmars-d-learn
On Wednesday, 30 November 2022 at 00:50:46 UTC, WebFreak001 wrote: ... Should there be an `intermediate layer` to simplify such function calls?

Re: How do I _really_ implement opApply?

2022-11-29 Thread zjh via Digitalmars-d-learn
On Wednesday, 30 November 2022 at 01:17:14 UTC, zjh wrote: Should there be an `intermediate layer` to simplify such function calls? There should be a `placeholder` similar to `inout` that can absorb all `attributes` of the parameter.

Re: Is there such concept of a list in D?

2022-12-10 Thread zjh via Digitalmars-d-learn
On Saturday, 10 December 2022 at 19:49:23 UTC, Salih Dincer wrote: SDB@79 Can the `range` be partially traversed? That is, suppose we only access the `[3,5)` elements?

Re: Is there such concept of a list in D?

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 07:47:35 UTC, Salih Dincer wrote: .. Thank you for your reply. I think if you take `random` values frequently, you'd better use `'array'`,am I right?

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 04:36:45 UTC, thebluepandabear wrote: "The main reason for this limitation is the fact that a function taking a ref parameter can hold on to that reference for later use, at a time when the rvalue would not be available." I only know that `rvalue` is a tempo

Re: Why can't rvalues be passed to a 'ref' parameter?

2022-12-11 Thread zjh via Digitalmars-d-learn
On Sunday, 11 December 2022 at 16:48:57 UTC, Ali Çehreli wrote: However, the situation has changed in D: It has been possible to pass rvalues by reference through the magic of 'in' parameters. This currently requires the -preview=in compiler switch, which makes 'in' parameters imply 'const sco

Re: Hipreme's #7 Tip of the day - Using the out parameters

2022-12-31 Thread zjh via Digitalmars-d-learn
On Saturday, 31 December 2022 at 17:13:16 UTC, Hipreme wrote: [...] Nice article.

Re: Problem with ImportC example?

2023-01-17 Thread zjh via Digitalmars-d-learn
On Tuesday, 17 January 2023 at 11:16:25 UTC, DLearner wrote: With the latest version of 'dmd101.2',`dmd a.c`, I get: C:\Windows Kits\10\Include\10.0.22000.0\ucrt\corecrt_wstdio.h|1208| Error: function `a.__vswprintf_l` redeclaration with different type C:\Windows Kits\10\Include\10.0.22000.0\u

Re: Problem with ImportC example?

2023-01-17 Thread zjh via Digitalmars-d-learn
On Wednesday, 18 January 2023 at 02:05:34 UTC, zjh wrote: < ... `nightly`: Unresolved external symbol `__va_start`, function `_fwprintf_`. link error.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear wrote: Hi, In Java/C# you can create purely static classes. ... Last time, someone proposed to add `private` like `C++'s`, and then it was the same,they are always unwilling to add facilities useful to others, and then he left `D

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:07:35 UTC, zjh wrote: they are always unwilling to add facilities useful to others, `D`'s community is small, this is the reason!

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-08 Thread zjh via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 12:12:57 UTC, thebluepandabear wrote: but I still think the language has potential in the future I don't know if they have a sense of crisis. Now `D` in tiebo ranks `50`.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:55:41 UTC, Guillaume Piolat wrote: yeah right let's implement everything that people propose I like the concept of C++: I provide `facilities`, you can use it or not. Not that you can only do it `like this`! This is the only way. What's more, people put f

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:07:56 UTC, thebluepandabear wrote: yeah the whole module behaviour with `private` is just a massive turn off tbh, it needs to be changed to match the Java style They don't even admit the smaller the encapsulation, the better.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:32:36 UTC, zjh wrote: They don't even admit the smaller the encapsulation, the better. Our predecessors used D very early. At first, they were very `excited`. But `later`, they left because some people in D were too `stubborn`. You can provide `facilities`,

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:41:27 UTC, zjh wrote: Our predecessors used D very early. At first, they were very `excited`. But `later`, they left because some people in D were too `stubborn`. Therefore, the community is very small. Our predecessors are `very smart` people, and they `l

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:49:03 UTC, zjh wrote: .. There are too `few newcomers` to D, and D must change. If I can, I think `'D++'` is a good idea! Learn from a `successful` language! The typical feature of `C++` is that you have it. Although I don't have it now, I will have it so

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 14:03:41 UTC, zjh wrote: If I can, I think `'D++'` is a good idea! Learn from a `successful` language! Don't be afraid of D becoming complex. C++ is already `super complex`. Aren't there more and more people still using it? Therefore, I don't approve of the

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: On 2/8/23 04:07, zjh wrote: Besides, D has zero problems with its private implementation in the sense that there has been zero bugs related to it being that way. In contrast, I use D every day and love its relaxed attitude tow

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Thursday, 9 February 2023 at 20:05:06 UTC, Ali Çehreli wrote: In contrast, I use D every day and love its relaxed attitude towards private. I admit that you use 'D' happy, but you don't admit that I use 'D' unhappy.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 February 2023 at 00:58:51 UTC, zjh wrote: I admit that you use 'D' happy, but you don't admit that I use 'D' unhappy. Right,just `forkit`. The `minority` language is more closed than the big language! If you think about it, you will know that the `'D'` ranking should fall!

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 February 2023 at 02:04:06 UTC, ProtectAndHide wrote: "Before practicing Zen, mountains were mountains and rivers were rivers. While practicing Zen, mountains are no longer mountains and rivers are no longer rivers. After realization, mountains are mountains and rivers are rivers

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread zjh via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 08:57:27 UTC, Mike Parker wrote: I meant to say, it "wouldn't add more". What if two classes in the module that are several meters apart make `mistakes` that change the privite variable of `another class`? No one can guarantee that after `a few months`, e

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread zjh via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 10:17:30 UTC, Mike Parker wrote: I referenced that in my post. The exact same problem exists *inside* the class when your class file is very long. You can easily manipulate the private member even when it's only supposed to be accessed by a specific function.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread zjh via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 09:57:56 UTC, ProtectAndHide wrote: In a module that contains a class, and other code as well (perhaps other tightly coupled classes), you can know **nothing** at all about that type (or any other class) without knowing **everything** else in the module. If o

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-15 Thread zjh via Digitalmars-d-learn
On Wednesday, 15 February 2023 at 12:44:19 UTC, zjh wrote: Right... They greatly increase your code maintenance work! Many people left D because of these small details! Their encapsulation can actually leakage class members. Programmers in other languages will laugh cry!

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-16 Thread zjh via Digitalmars-d-learn
On Thursday, 16 February 2023 at 22:25:22 UTC, ProtectAndHide wrote: also, I noticed that you intentionally? did not respond to the facts that I outlined: ie. They can't refute you, so they have to blame you. You can't wake up who pretend to sleep.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-16 Thread zjh via Digitalmars-d-learn
On Friday, 17 February 2023 at 01:13:59 UTC, zjh wrote: They can't refute you, so they have to blame you. You can't wake up who pretend to sleep. They don't admit their mistakes! And `D` community is getting smaller and smaller! If I were D author , I would suspect that they are undercover

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-16 Thread zjh via Digitalmars-d-learn
On Friday, 17 February 2023 at 01:21:18 UTC, zjh wrote: They don't admit their mistakes! And `D` community is getting smaller and smaller! Because other languages laughs cry! `D` don't even have `type-safe` classes. The ability of a group of people to open their eyes and tell lies is really

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-17 Thread zjh via Digitalmars-d-learn
On Saturday, 18 February 2023 at 06:55:49 UTC, ProtectAndHide wrote: No, I think D is not for me. They don't care about the needs of `D` users! They won't listen ,even if you said it thousand times.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 March 2023 at 02:48:43 UTC, John Xu wrote: ```d module chinese; import std.stdio : writeln; import std.conv; import std.windows.charset; int main(string[] argv) { auto s1 = "中文";//utf8 字符串 writeln("word:"~ s1); //乱的 writeln("word:" ~ to!string(toMBSz(text(s

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-09 Thread zjh via Digitalmars-d-learn
On Friday, 10 March 2023 at 06:19:38 UTC, zjh wrote: `D language` is too unfriendly for Chinese users! You can't even write `gbk` files.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-11 Thread zjh via Digitalmars-d-learn
On Saturday, 11 March 2023 at 19:56:09 UTC, 0xEAB wrote: If you desire to use other encodings, how about using ubyte + ubyte[]? There is no example. An example should be added in an obvious position. I tried for a long time, but couldn't output `gbk`, and I finally gave up.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-12 Thread zjh via Digitalmars-d-learn
On Sunday, 12 March 2023 at 20:03:23 UTC, 0xEAB wrote: ... Thank you for your reply, but is there any way to output `gbk` code to the console?

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-13 Thread zjh via Digitalmars-d-learn
On Monday, 13 March 2023 at 15:50:37 UTC, Steven Schveighoffer wrote: What is required is an addition to the `std.encoding` module, to allow such an encoding. Thank you for your information.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-14 Thread zjh via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 09:20:54 UTC, Kagamin wrote: I guess if your console is in gbk encoding, you can just write bytes with stdout.write. Thank you for your reply, but only display bytes, not gbk text.

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-22 Thread zjh via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 15:23:42 UTC, Kagamin wrote: https://dlang.org/phobos/std_stdio.html#rawWrite It's really amazing, it succeeded. Thank you! ```cpp auto b="test.txt";//gbk void[]d=read(b); stdout.rawWrite(d); ```

Re: Implicit type conversion depending on assignment

2023-03-23 Thread zjh via Digitalmars-d-learn
On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov wrote: Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to use an alias to this, but it can only be used 1 time } auto a = MyVa

C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
```d import core.stdc.stdio; struct A{ static int e=40; struct B{ int m; this(int i){ printf("%i",e);m=i; } ~this(){ e=m; printf("%i",e); } } void f(){ B b=e;e=6; } void g(){ printf

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Thursday, 15 June 2023 at 21:48:10 UTC, Ali Çehreli wrote: And this is by design: In D, we rename the type and be done with it. In C++, one needs to rename a number of functions as well. Ali ```d static int e=40; struct B{ int m; this(int i){ printf(

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Thursday, 15 June 2023 at 21:48:10 UTC, Ali Çehreli wrote: I have difficulty understanding the question. I think the nested structs, extern(C), static members, etc. confuse me. I am assuming they are not related to this question. Ali I used the `class` to call the` constructor/destr

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Friday, 16 June 2023 at 00:35:48 UTC, Steven Schveighoffer wrote: But there is no way in D to have e.g.: ```d B b; // runs a constructor ``` -Steve As a `C++` user, it is very terrible to simplify `RAII` without such a method. Why must `this()` be disabled? Can't there be a constructor?

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Friday, 16 June 2023 at 00:35:48 UTC, Steven Schveighoffer wrote: Instead, you can use factory functions to initialize. -Steve How can `factory functions` be used to achieve effects similar to `'RAII'`? Thank you.

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Friday, 16 June 2023 at 01:00:05 UTC, Steven Schveighoffer wrote: B b = B.make(); // call factory function -Steve Thank you for your tip. If could simplify it a bit more, it would be even better. It's really uncomfortable without `this()`.

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Friday, 16 June 2023 at 01:45:35 UTC, CM wrote: ```d auto m = Man(); assert(m.name == defaultName); ``` Do note that one cannot simultaneously have a constructor and a static opCall, even if their parameters differ. Thank you for your reply. This should be enough, as this type of RAII is

Re: C++'s this() equivalent?

2023-06-15 Thread zjh via Digitalmars-d-learn
On Friday, 16 June 2023 at 01:54:22 UTC, Jonathan M Davis wrote: ```d doSomething(); scope(exit) undoSomething(); ``` Thank you for your `wonderful summary`. It's worth saving the link.

Re: struct initializer

2023-11-30 Thread zjh via Digitalmars-d-learn
On Wednesday, 29 November 2023 at 16:38:36 UTC, Dom DiSc wrote: ```d struct S { int a; int b; } S2 fun3() { return S2( 5, 2 ); } ``` Here,`S2( 5, 2 );` violeit `DRY` principle.

Re: struct initializer

2023-12-01 Thread zjh via Digitalmars-d-learn
On Friday, 1 December 2023 at 13:02:06 UTC, Dom DiSc wrote: ```d S Fun(){ return { 5, 2 }; } ``` This IS an initialization and the type is known. Requiring the repetition of the type is also here annoying. Right. The `{}` initialization method in C++ is very useful,I like it very much.

vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
```d import dparse.ast; import dparse.lexer; import dparse.parser : parseModule; import dparse.rollback_allocator : RollbackAllocator; import core.stdcpp.vector; import core.stdcpp.string; Vector!string d=[];toV(a,d); print(d);//3 foreach(e;d){ string b=d[i]; string m=readText(b);ff(m,b);

Re: vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
On Thursday, 18 January 2024 at 03:07:13 UTC, zjh wrote: Why can `b` still affect `e` here? Isn't `b` copied? here foreach crashes. Starting from the `third one`, it crashes. It's clearly `vector.d`, but the result is`+Object`. ```d string b=d[i];//the 3th:vector.d //`+Object`,crashes! ```

Re: vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
On Thursday, 18 January 2024 at 03:11:57 UTC, zjh wrote: ```d string b=d[i];//the 3th:vector.d //`+Object`,crashes! ``` ```d //d[i]==>e string b=e; ``` in the foreach.

Re: vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
On Thursday, 18 January 2024 at 03:53:09 UTC, Steven Schveighoffer wrote: Are you sure this is what you are wanting to do? -Steve ```d void gg(string a){ Vector!string d=[];toV(a,d);//File to Vector print(d);//3,OK foreach(e;d){ string b=e;//.1 string m=readText(b

Re: vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
On Thursday, 18 January 2024 at 04:20:12 UTC, zjh wrote: foreach(e;d){ ```d foreach(e;d){//.0 string b=e; string m=readText(b);ff(m,b); } ``` or here `.0`? why crash?

Re: vector crash

2024-01-17 Thread zjh via Digitalmars-d-learn
On Thursday, 18 January 2024 at 04:24:18 UTC, zjh wrote: ```d class V : ASTVisitor { Vector!string f=[]; alias visit = ASTVisitor.visit; override void visit(const FunctionDeclaration decl) { writeln(' '.repeat(indentLevel * 4), decl.name.text); f.push_back(decl.nam

  1   2   >