On Thursday, 4 November 2021 at 01:29:57 UTC, jfondren wrote:
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
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([0], "Hello World!");
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 ;)
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
On 11/2/21 9:06 PM, tsbockman wrote:
UFCS works for setters, too:
Oh yeah! Pretty cool. :)
Ali
On Monday, 1 November 2021 at 21:32:21 UTC, Ali Çehreli wrote:
Joking aside, I liked the nested struct and its opAssign to
mimic internal `arr.length = 42` syntax. (I know it involves a
potentially expensive delegate but still...)
The nested struct is not needed. UFCS works for setters, too:
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 please, do NOT study this code. It is bad all around. Ali should
know
On Monday, 1 November 2021 at 21:37:59 UTC, Ali Çehreli wrote:
On 11/1/21 2:28 PM, pascal111 wrote:
> This can serve the style I want.
I am feeling funny right now and showing incorrect code. It's
impossible to fit "Hello World!" in "xyz". As Steve said, don't
do that. :)
> It uses OOP
On Monday, 1 November 2021 at 21:32:21 UTC, Ali Çehreli wrote:
On 11/1/21 2:01 PM, Ali Çehreli wrote:
> The program is as incorrect as its C equivalent would be. ;)
I wrote a cool function to make it easy to disregard memory
safety:
import std.stdio;
auto assumedLength(S)(ref S slice) {
On 11/1/21 2:28 PM, pascal111 wrote:
> This can serve the style I want.
I am feeling funny right now and showing incorrect code. It's impossible
to fit "Hello World!" in "xyz". As Steve said, don't do that. :)
> It uses OOP style like C++ by putting a
> pointer as a property,
D's slices are
On 11/1/21 2:01 PM, Ali Çehreli wrote:
> The program is as incorrect as its C equivalent would be. ;)
I wrote a cool function to make it easy to disregard memory safety:
import std.stdio;
auto assumedLength(S)(ref S slice) {
struct LengthSetter {
void opAssign(size_t length) {
//
On Monday, 1 November 2021 at 21:01:31 UTC, Ali Çehreli wrote:
On 11/1/21 1:49 PM, pascal111 wrote:
> Yes, I'm practicing doing things in low level style like
standard C.
All you needed extra was to let the slice know about the new
length:
import std.stdio;
import core.stdc.string;
void
On 11/1/21 1:49 PM, pascal111 wrote:
> Yes, I'm practicing doing things in low level style like standard C.
All you needed extra was to let the slice know about the new length:
import std.stdio;
import core.stdc.string;
void main() {
char[] s="xyz".dup;
strcpy([0], "Hello World!");
s =
On Monday, 1 November 2021 at 20:15:14 UTC, Steven Schveighoffer
wrote:
On 11/1/21 3:56 PM, 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:
{
On 11/1/21 3:56 PM, 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([0], "Hello World!");
writeln(s);
}
Result:
I know that I can use the next syntax to assign new value to char
dynamic array, and the new value isn't in same length of the
current value of the array:
{
char[] s="xyz".dup;
s="Hello World!".dup;
writeln(s);
}
Result:
Hello World!
=
But what if I want to use
16 matches
Mail list logo