8

I have this class:

TMyClass = class
public
  function DoSomethingNice(const Value: string = 'Yes please!'): Boolean;
end;

Now, using RTTI, is it possible to get default value of parameter Value of method DoSomethingNice? if so, how?

I'm mostly interested in a D2010 solution, but XE will do also.

  • 2
    for now is not possible, but you can vote in this [QC 93943](http://qc.embarcadero.com/wc/qcmain.aspx?d=93943) – RRUZ Feb 26 '12 at 11:24
  • @RRUZ thank you, I wasn't sure about this, but was expecting it... –  Feb 26 '12 at 12:00

1 Answers1

14

it is impossible, because RTTI has not information about default parameters. default parameter values are used only at compile time

so, if we have... procedure test(x : integer = 3) and then call method without parameter value: test() then it will be compiled as test(3)

to check this you can open CPU window in debugger: and test() looks like

 mov  eax, $00000003
 call test
teran
  • 3,214
  • 1
  • 21
  • 30