[fpc-pascal] Optional param modifier

Sven Barth pascaldragon at googlemail.com
Sun Apr 14 09:15:16 CEST 2019


Ryan Joseph <ryan at thealchemistguild.com> schrieb am So., 14. Apr. 2019,
00:17:

>
>
> > On Apr 13, 2019, at 6:01 PM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > Well, there is Oxygene's concept of Class Contracts (see
> > https://docs.elementscompiler.com/Concepts/ClassContracts/ ), so if
> > anything in that direction would be done I'd be inclined towards their
> > syntax (and I've played with the idea to implement this in FPC for quite
> > some time already).
>
> That’s an interesting idea. It’s certainly common that you test for these
> conditions at the top of the function and have bail out conditions so it
> makes sense to pull it out into syntax. But it has to rely on exceptions
> and all that overhead? That’s not so great if so.


Your idea requires exceptions as well. The compiler is not capable checking
whether valid entries are passed in at compile time except for simple,
constant cases, so runtime checks are needed and the only way to abort
something is by exceptions.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190414/78852810/attachment.html>


More information about the fpc-pascal mailing list