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

2022-05-11 Thread Siemargl 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 When i take old library from a dub or github and cannot compile it

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: range result in Tuple! and how to convert into assocArray by sort?

2022-05-11 Thread forkit via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 03:22:04 UTC, MichaelBi wrote: s is the string, and print result as following: s.array.sort!("athen how to transfer into [['A',231],['C',247],['G',240],['T',209]]? tried map!, but can only sortout key or value... tried array(), but result is not sorted

Re: Virtual methods on stack objects

2022-05-11 Thread dangbinghoo via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 20:53:21 UTC, Marvin Hannott wrote: On Wednesday, 11 May 2022 at 20:23:07 UTC, Ali Çehreli wrote: [...] Yeah, but you can't return `Cat` . And the documentation for `scoped` says: [...] That's kinda very limiting. Anyway, I cooked up another idea based on

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 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 Steven Schveighoffer via Digitalmars-d-learn
On 5/11/22 9:06 PM, Christopher Katko wrote: I just realized foreach copies by value by default. Maybe. Sometimes. When? I don't even know anymore. Because I "thought" I had to use foreach(ref) to be able to affect the original data structure (because by value means its a copy, right?).

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

2022-05-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 12 May 2022 at 01:06:02 UTC, Christopher Katko wrote: completely different semantics for a class vs a struct. Is it a reference? Is it a value? Look up the entire declaration and have the entire Dlang manual open to find out. As far as I remember, no automatic RAII support, even

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

2022-05-11 Thread Christopher Katko 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 Every time I think I understand D, I don't. Cool useful library

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

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 11:27, templatedperson wrote: > I don't know if this counts as a feature, but reading the standard > library documentation was especially difficult. There are a ton of > `auto`s everywhere and function signatures are hard to read because of > that. I got used to confusing function

Re: Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 20:23:07 UTC, Ali Çehreli wrote: On 5/11/22 13:06, Marvin Hannott wrote: > I appreciate the answer, don't much like the "solutions". Me neither. :) > It's not so much about copying Great! > scoped class objects should have value semantics. std.typecons.scoped

Re: range result in Tuple! and how to convert into assocArray by sort?

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/9/22 22:12, MichaelBi wrote: > On Tuesday, 10 May 2022 at 04:21:04 UTC, Ali Çehreli wrote: >> On 5/9/22 20:38, rikki cattermole wrote: >> >> > [...] >> >> Yes! :) >> >> Assuming the data is indeed validated in some way, the following >> should be even faster. It validates the data after the

Re: Virtual methods on stack objects

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 13:06, Marvin Hannott wrote: > I appreciate the answer, don't much like the "solutions". Me neither. :) > It's not so much about copying Great! > scoped class objects should have value semantics. std.typecons.scoped does exactly that:

Re: Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 14:44:59 UTC, Ali Çehreli wrote: On 5/11/22 06:57, Marvin Hannott wrote: > I understand that D's classes solve some particular problems. However, > they also cause problems because they cannot be copied when scoped. So > how do I get virtual methods on a copyable

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

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 12:20, Ola Fosheim Grøstad wrote: > 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. > > Also, if you intend to use the responses for planning purposes No. :) I was hoping to get

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

2022-05-11 Thread Ola Fosheim Grøstad 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. Also, if you intend to use the responses for planning purposes, keep in mind that people who read the forums regularly are more informed about

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

2022-05-11 Thread Guillaume Piolat 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. - How to do deterministic destruction with programs that use everything (struct / class / dynamic dispatch / GC / manual / etc). This requires to

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

2022-05-11 Thread templatedperson 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 if this counts as a feature, but reading the standard library documentation was especially difficult. There are a ton of `auto`s

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

2022-05-11 Thread Ola Fosheim Grøstad 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. No singular feature, but the overall cognitive load if you use the language sporadic. Which could be most users that don't use it for work or have it

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

2022-05-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 09:06:52 UTC, bauss wrote: 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 dip1000

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

2022-05-11 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 11, 2022 at 03:34:12PM +, Paul Backus via Digitalmars-d-learn wrote: > On Wednesday, 11 May 2022 at 15:10:28 UTC, Tejas wrote: > > That'll be true the day when `@safe` becomes the default... Until > > then, I'll atleast do `@safe:` on top of every module :) > > `@safe:` is

Re: Trait for "can be instantiated"?

2022-05-11 Thread Ben Jones via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 12:29:05 UTC, Basile B. wrote: How about being more explicit in the UDA ? The idea would be to associate the enum value to a type or not: I think that could work but would require some major changes to my existing code. Also, I think I'd prefer: ``` @Token{

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

2022-05-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 15:10:28 UTC, Tejas wrote: That'll be true the day when `@safe` becomes the default... Until then, I'll atleast do `@safe:` on top of every module :) `@safe:` is actually a bad idea if you're writing templated code, because it turns inference of `@system` into a

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

2022-05-11 Thread Tejas via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 14:20:07 UTC, H. S. Teoh wrote: On Wed, May 11, 2022 at 01:37:21PM +, matheus via Digitalmars-d-learn wrote: > [...] [...] [...] [...] My suggestion is: when prototyping, don't even think about attributes. Just templatize your functions and let the compiler

Re: Virtual methods on stack objects

2022-05-11 Thread Ali Çehreli via Digitalmars-d-learn
On 5/11/22 06:57, Marvin Hannott wrote: > I understand that D's classes solve some particular problems. However, > they also cause problems because they cannot be copied when scoped. So > how do I get virtual methods on a copyable stack object? Problems classes solve don't usually need copying

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

2022-05-11 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 11, 2022 at 01:37:21PM +, matheus via Digitalmars-d-learn wrote: > 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

Virtual methods on stack objects

2022-05-11 Thread Marvin Hannott via Digitalmars-d-learn
Hi everybody! I understand that D's classes solve some particular problems. However, they also cause problems because they cannot be copied when scoped. So how do I get virtual methods on a copyable stack object?

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

2022-05-11 Thread matheus 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 I don't know if this will be helpful but here it goes, my user case

Re: Trait for "can be instantiated"?

2022-05-11 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 16:10:26 UTC, Ben Jones wrote: On Tuesday, 10 May 2022 at 16:05:15 UTC, H. S. Teoh wrote: Using wrapper structs, etc., for this is IMO total overkill. Just use an enum for your token types. Something like this would suffice: That's basically what sumtype is going

Re: While loop on global variable optimised away?

2022-05-11 Thread ichneumwn via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 10:01:18 UTC, Johan wrote: Any function call (inside the loop) for which it cannot be proven that it never modifies your memory variable will work. That's why I'm pretty sure that mutex lock/unlock will work. Thank you, in C I would not have been surprised. It

Re: While loop on global variable optimised away?

2022-05-11 Thread Johan via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 09:34:20 UTC, ichneumwn wrote: Hi Forum, I have a snippet of code as follows: ``` extern(C) extern __gshared uint g_count; // inside a class member function: while(g_count) <= count) {} ``` This is from a first draft of the code without proper thread

Re: While loop on global variable optimised away?

2022-05-11 Thread rikki cattermole via Digitalmars-d-learn
Compiler optimizations should not be defined by a programming language specification. This will be on LLVM.

While loop on global variable optimised away?

2022-05-11 Thread ichneumwn via Digitalmars-d-learn
Hi Forum, I have a snippet of code as follows: ``` extern(C) extern __gshared uint g_count; // inside a class member function: while(g_count) <= count) {} ``` This is from a first draft of the code without proper thread synchronisation. The global variable g_count is updated from a bit of

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

2022-05-11 Thread bauss 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 dip1000