[fpc-pascal] Optional param modifier
Martin Frb
lazarus at mfriebe.de
Sat Apr 13 23:11:53 CEST 2019
On 13/04/2019 22:34, Ryan Joseph wrote:
>
> I can find many hundreds of examples like the one above in the Cocoa frameworks since Apple retroactively added them in. I don’t understand why you think this is a minor subset of cases.
That "minor set" referred to compiler warnings you get, inside a
function that has an optional argument, if you do not check that
argument for nil:
Objects that are nil happen everywhere in the code. The amount of
object accesses with potential nil issues that will be in the scope of
such an optional parameter is minor compared to the amount of overall
such accesses.
The amount of method declaration that could benefit from additional
clarity towards what values they can take in there arguments (and
hopefully deductible from that their purpose) may indeed be noticeable.
But for that there should be better solutions. Not at least because
nil-ability is only one such concern.
Were it only the documentation of nil-ability then comments would do the
job.
When it is about a more generic approach then see the wikipage about
contracts. (I did mail a link)
More information about the fpc-pascal
mailing list