December 08, 2022
On 12/8/22 08:21, Salih Dincer wrote:

> void stringCopy(Chars)(string source,
>                      ref Chars target)

>    sample.stringCopy = cTxt;  // disappeared ? char

Nothing disappeared on my system. (?)

Going off-topic, I find the expression above extremely confusing. I am used to assignment expression changing the value of the left hand side, but that expression changes cTxt. Very confusing...

Such obfuscations make it very hard for me to understand what the code is trying to demonstrate.

Ali

December 08, 2022

On Thursday, 8 December 2022 apt 17:39:58 UTC, Ali Çehreli wrote:

> >
void stringCopy(Chars)(string source,
                     ref Chars target)

   sample.stringCopy = cTxt;  // disappeared ? char

I find the expression above extremely confusing. I am used to assignment expression changing the value of the left hand side, but that expression changes cTxt.

You're right, it's my fault. Copy commands are always used as source on the left and target on the right. I have to get rid of this habit. Immediately I'm swapping parameters and fixing...


  stringCopy(cText, sample); // or
  cText.stringCopy(sample):  // or
  cText.stringCopy = sample; // tricky 😀

@SDB79

December 10, 2022
On Thursday, 8 December 2022 at 17:39:58 UTC, Ali Çehreli wrote:
> On 12/8/22 08:21, Salih Dincer wrote:
>
> > void stringCopy(Chars)(string source,
> >                      ref Chars target)
>
> >    sample.stringCopy = cTxt;  // disappeared ? char
>
> Nothing disappeared on my system. (?)
>
> Going off-topic, I find the expression above extremely confusing. I am used to assignment expression changing the value of the left hand side, but that expression changes cTxt. Very confusing...
>
> Such obfuscations make it very hard for me to understand what the code is trying to demonstrate.

Yes, with function call syntax it's more understandable if an argument is modified.

It was bizarre and confusing that assignment syntax was implemented for functions and methods not explicitly marked with @property.

December 18, 2022

On Saturday, 10 December 2022 at 11:13:57 UTC, Nick Treleaven wrote:

>

It was bizarre and confusing that assignment syntax was implemented for functions and methods not explicitly marked with @property.

Hi Nick, do you think this is confusing?

void main()
{
  struct S
  {
    int value;

    alias opCall this;
    this(int i) {
      value = i;
    }

    alias opAssign = opCall;
    @property opCall(int x) {
      return value = x;
    }

    @property opCall() inout {
      return value;
    }

    @property opOpAssign(string op)(int x) {
      mixin("return value"~op~"=x;");
    }
  }

  S a = S(10),
    b = S(-1);

  import std.stdio;
  writeln(a + b); // 9
  writeln(++a + b); // 10
}

Actually, my question to everyone is, for example, is this kind of wrapping confusing for you?

SDB@79

1 2
Next ›   Last »