[fpc-pascal] Optional param modifier

Ryan Joseph ryan at thealchemistguild.com
Sat Apr 13 01:00:01 CEST 2019



> On Apr 12, 2019, at 3:52 PM, Jonas Maebe <jonas at freepascal.org> wrote:
> 
> Normally, if it can't accept nil it should be var-parameter, and if it can then it should be a pointer.
> 
> This becomes less clear if a parameter type is already an implicit pointer type (like a class or interface), but there are fewer case of that kind.

I actually suggest this solely for the use of pointer types in order to:

1) prevent nil pointer dereferencing (do I need to check for nil on this parameter/return value or is it safe to access?)
2) self documenting code (can this parameter accept nil?)

Using var and pointers to pointers are possible workarounds but they’re not really expressing what we mean so it seemed logical to add this to the list of parameter modifiers already existing.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list