AArhin / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Support default values for "const" parameters #302

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently default values are only supported for non-const parameters.

Original issue reported on code.google.com by zar...@gmail.com on 17 Oct 2012 at 3:14

GoogleCodeExporter commented 9 years ago
Is there any reason why this isn't as simple as removing the two lines that 
raise this error from TdwsCompiler.ReadParams?

Original comment by masonwhe...@gmail.com on 3 Jul 2014 at 2:59

GoogleCodeExporter commented 9 years ago
Const parameter are passed by reference rather than by value, so some 
adaptation may be needed in the calls, as the reference to the default value 
wouldn't be on the stack.

Also non-const parameters with a default value are described with 
TParamSymbolWithDefaultValue (a TParamSymbol), while const params are 
TConstParamSymbol (a TByRefParamSymbol), so it would have to be subclassed, and 
support added in all locations in the code where TConstParamSymbol or 
TByRefParamSymbol appears.

Another subtlety would be when matching two function prototypes where the const 
params have or don't have default values, or have different values, I'm not 
entirely sure what Delphi accepts in that area. By matching I mean for function 
type matching, function pointer acquisition, overrides, overloads and interface 
methods identifications.

Original comment by zar...@gmail.com on 3 Jul 2014 at 3:32