Yes, there are many small troubles, and the syntax makes the method signatures more complex and heavier.
The annotations like &self(mut x)
or use self.x
are ways to specify what fields a method is allowed to use. So they are ways to better specify the flow of information between the methods of a struct. This is handy even in regaular OOP in languages like Java/D. Sometimes in those languages I've desired a way to know what fields a method is allowed to use. In D you can only specify a method to be const, immutable, or mutable, regarding its usage of instance fields. But an annotation like that is able to give a more granular information.
The syntax &self(mut x)
gives more information than use self.x
, because it also specifies that the field x will be mutated (and the compiler could even give an error if you don't mutate x). This means an annotation like &self(mut x, y)
means that x will be written while y will be just read.
A fully specified syntax could use in
, out
, and inout
, like: &self(in x, out y, inout z)
, this gives information regarding what instance variables are read, written, and read and written by the method. Static analysers like this kind of information a lot.
This kind of knowledge about the flow of information between methods is quite related to the #[outer()]
annotation I discussed in past, the purpose is almost the same: