printf, writeln, writefln
j
my.email at gmail.com
Sun Dec 18 20:51:35 UTC 2022
On Sunday, 18 December 2022 at 16:17:40 UTC, Salih Dincer wrote:
> 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?
>
> ```d
> 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 at 79
Yes
More information about the Digitalmars-d-learn
mailing list