Re: Using "strcpy" to assign value to dynamic char array

2021-11-03 Thread Ali Çehreli via Digitalmars-d-learn
On 11/2/21 9:06 PM, tsbockman wrote: UFCS works for setters, too: Oh yeah! Pretty cool. :) Ali

Re: GC memory fragmentation

2021-11-03 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 06:26:49 UTC, Heromyth wrote: On Wednesday, 14 April 2021 at 12:47:22 UTC, Heromyth wrote: On Sunday, 11 April 2021 at 09:10:22 UTC, tchaloupka wrote: Hi, we're using vibe-d (on Linux) for a long running REST API server and have problem with constantly growing

Re: Using "strcpy" to assign value to dynamic char array

2021-11-03 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 02:38:56 UTC, Steven Schveighoffer wrote: On 11/1/21 9:03 PM, pascal111 wrote: On Monday, 1 November 2021 at 21:32:21 UTC, Ali Çehreli wrote: Joking aside ... This function seems smart and flexible and higher than my current level, I'll study it. Please

Re: Using "strcpy" to assign value to dynamic char array

2021-11-03 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 10:38:45 UTC, pascal111 wrote: On Wednesday, 3 November 2021 at 02:38:56 UTC, Steven Schveighoffer wrote: On 11/1/21 9:03 PM, pascal111 wrote: [...] [...] ... [...] Please please, do NOT study this code. It is bad all around. Ali should know better ;)

Re: Completing C code with D style

2021-11-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 00:50:51 UTC, Siarhei Siamashka wrote: !text.join("\n").writeln; Ahem... You've turned a program that does not allocate to a program that allocates who knows how much memory? And Ali... associative arrays? For this? What are you trying to teach the goo

Re: Completing C code with D style

2021-11-03 Thread russhy via Digitalmars-d-learn
The code "as is" is perfectly fine I don't understand why you guys offer OP such complicate/bloated examples, it'll only make things confusing and slow down compilation time with templates and imports, this is not needed at all One change, use .length property instead of the hardcoded value

Re: Completing C code with D style

2021-11-03 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote: I don't understand why you guys offer OP such complicate/bloated examples, it'll only make things confusing and slow down compilation time with templates and imports, this is not needed at all I don't like complicated things either

Re: Completing C code with D style

2021-11-03 Thread Ali Çehreli via Digitalmars-d-learn
On 11/3/21 11:41 AM, Stanislav Blinov wrote: > And Ali... associative arrays? For this? What are you trying to teach > the good beginner here? :D Obviously, we're all enjoying this thread but once the OP made it clear that they wanted a C-like solution, I took some liberty with alternative sol

Re: Completing C code with D style

2021-11-03 Thread jfondren via Digitalmars-d-learn
On Wednesday, 3 November 2021 at 20:36:08 UTC, russhy wrote: Keeping things simple helps debugging! I'd still have to run your program to be sure of its simple logic, though. The real star d feature that would help with debugging is unittest: ```d enum sign { negatives = 'n', positives = 'p

Re: Using "strcpy" to assign value to dynamic char array

2021-11-03 Thread jfondren via Digitalmars-d-learn
On Monday, 1 November 2021 at 19:56:13 UTC, pascal111 wrote: But what if I want to use "strcpy" function to assign that new value to the array that the problem is that the array won't take more than its first initializing value length: { char[] s="xyz".dup; strcpy(&s[0], "Hello World!"); wr