<HTML><BODY><div>Let me also share the results of tests for method pointers with different default values. The example is a bit convoluted, but it shows all possible combinations. It turns out that any component event definition always overrides the default values from the class.</div><div> </div><div><div><div><div><div>program Project1;</div><div>type</div><div> TTest = class</div><div> procedure test(a: string; b: string = 'class');</div><div> end;</div><div> TReq = procedure (a, b: string) of object;</div><div> TOpt = procedure (a: string = 'def1'; b: string = 'def2') of object;</div></div><div> </div><div><div>procedure TTest.test(a: string; b: string);</div><div>begin</div><div> writeln(a, ', ', b);</div><div>end;</div></div><div> </div><div><div>var</div><div> lReq: TReq;</div><div> lOpt: TOpt;</div><div> lTest: TTest;</div><div>begin</div><div> lTest := TTest.Create;</div><div> lReq := @lTest.test;</div><div> lOpt := @lTest.test;</div></div><div> </div><div><div> lReq('req1', 'req2');</div><div> lOpt;</div><div> TOpt(lReq);</div><div> TReq(lOpt)('opt1', 'opt2');</div><div>end.</div></div></div></div></div><div data-signature-widget="container"><div data-signature-widget="content"><div> </div></div></div><div> </div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Среда, 23 октября 2024, 2:28 +05:00 от Martin Frb via fpc-devel <fpc-devel@lists.freepascal.org>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_17296325040679208688_BODY">Is the below meant to be allowed?<br>It compiles, it also compiles if you have no default in the base, but a<br>default in the sub class.<br><br>type<br> TFoo = class<br> procedure Bar (const Item: String; AnObject: TObject = nil); virtual;<br> end;<br> TFoo2 = class(TFoo)<br> procedure Bar (const Item: String; AnObject: TObject); override;<br> end;<br><br><br>It even works with both having a diff default.<br><br> TFoo = class<br> procedure Bar (const Item: String; AnObject: integer = 1); virtual;<br> end;<br> TFoo2 = class(TFoo)<br> procedure Bar (const Item: String; AnObject: integer=2); override;<br> end;<br><br>_______________________________________________<br>fpc-devel maillist - <a href="/compose?To=fpc%2ddevel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a><br><a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a></div></div></div></div></blockquote><div> </div></BODY></HTML>