[fpc-pascal] Generic type conflicts
Sven Barth
pascaldragon at googlemail.com
Wed Nov 6 18:44:10 CET 2019
Ben Grasset via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mi., 6. Nov. 2019, 15:43:
> On Wed, Nov 6, 2019 at 2:01 AM Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
>
>> A normal if-statements has the same non-evaluation.
>>
>
> Not in the way I meant, though.
>
> Like, I thought the difference between "normal if" and "ternary if" was
> supposed to be the same as the difference between the existing IfThen()
> function and the intrinsic version of IfThen(), on which you based the
> "if-then-else" syntax I think.
>
No. The difference between the currently provided IfThen<> generic is the
same in regards to evaluation to the rejected IfThen intrinsic, an
if-expression and an if-statement: All four typecheck their branches, but
only the later three don't execute the statements in the branch that is not
taken (and also have a branch optimised away if the condition is const).
The only difference between the if-expression and the if-statement is that
the former can be used as an expression (duh!).
The point being that the type-checking is neither useful or necessary in
> scenarios where the branch being evaluated is statically known to be
> unreachable ahead of time.
>
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.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20191106/bf964e8b/attachment.html>
More information about the fpc-pascal
mailing list