Closed 1316346949 closed 4 years ago
[Set] “a” will be written to the log because a is already set by class C. From the log we can know that a has been set by class C, so we can find the problem through the log.
But [Define] “a” cannot.
class A may have many fields, we can't understand how these fields are implemented
According to the proposal-decorators hint, if we don't know how many fields there are in class A, we can only write this code to ensure that the logging function performs normally.
In most cases we don't know how many fields there are in class A. We can only write -> @set xxx = xxx
So in most cases, [Define ] will not be used, because we don't know how many fields the parent class has, and what these fields look like. We pretend to use [Define ]. There may be bugs without prompting. just can use "@set xxx = xxx or construtor" to ensure that the program runs normally, or to fully understand all the fields of the parent class, use [Define ]
Sorry my english is not good, is there a clear description
Please try to keep your description in a single comment. It's really hard to read through multiple "answers".
I don't understand how this issue is related to [[Set]]
vs [[Define]]
. Even with [[Set]]
, the superclass won't log anything for b =
and c =
, because you didn't define setters for these properties.