String message methods and the self parameter
Original Reporter info from Mantis: Ewald
-
Reporter name:
Original Reporter info from Mantis: Ewald
- Reporter name:
Description:
When reading https://www.freepascal.org/docs-html/ref/refsu31.html#x82-1040006.5.7 I stumbled on the following text at the bottom of the page:
"In addition to this mechanism, a string message method accepts a self parameter:
Procedure StrMsgHandler(Data: Pointer;
Self: TMyObject); Message ’OnClick’;
When encountering such a method, the compiler will generate code that loads the Self parameter into the object instance pointer. The result of this is that it is possible to pass Self as a parameter to such a method.
Remark: The type of the Self parameter must be of the same class as the class the method is defined in."
I observe that the above code snippet fails to compile with the message "Message handlers can take only one call by ref. parameter"
When asked on the mailing list, this seems to be a documentation issue:
"Judging from the implementation inside the RTL I'd say that this is a bug in the documentation. String message methods work like ordinal ones and take only one parameter."
Mantis conversion info:
- Mantis ID: 33016
- Build: SVN rev. 30487
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 1468 (#302f891b)
- Target version: 3.2.0