Am 07.11.2019 um 01:33 schrieb Ben Grasset via fpc-pascal:
On Wed, Nov 6, 2019 at 12:44 PM Sven Barth via fpc-pascal <fpc-pascal@lists.freepascal.org <mailto:fpc-pascal@lists.freepascal.org>> wrote:

    Pascal has a strong type safety, thus something like the
    if-expression won't be used/allowed to weaken that.

    If that means that some things can't be implemented in generics
    the "easy" way, then so be it.


I agree that Pascal has strong type safety.

IMO conditional branching based on compile-time constant evaluation, that cannot fail, does not do anything resembling weakening it, however.

It strengthens it, and has no downsides, because it's verified by the compiler.

Encouraging typecasting (which cares only about the sizes of the types involved, nothing else) at the programmer level is far more error-prone in a variety of ways.
If there is no type checking, then it is *not* verified by the compiler. If I have an if-expression with an always true if-clause I could write any syntactically correct garbage in the else-clause if type checking would be disabled, because the compiler would not verify it. And this is not how Pascal works. And also not how FPC's parser works. We're taking huge care that generics are correctly type checked and that as many errors as possible are caught when writing the generic (instead of when specializing), so we're not going to introduce something like this. The if-expression is intended to be like C/C++'s ternary operator nothing more, nothing less cause that is what most people want to use it for.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to