Sigh, thought everyone (eventually) agreed that we'd change to algol/ada
x:=if a>b then 1 else 2; so why are we going on & on & on about this?

john

On 2 February 2016 at 13:20, Sven Barth <pascaldra...@googlemail.com> wrote:

> Am 02.02.2016 11:42 schrieb "Mark Morgan Lloyd" <
> markmll.fpc-pas...@telemetry.co.uk>:
> >
> > Michael Van Canneyt wrote:
> >
> >> Call me old fashioned, but then I think
> >>   foo:=iif(Condition1,
> >>            iif(Condition2, ThenExpr1, ElseExpr1),
> >>            iif(Condition3, ThenExpr2, ElseExpr2));
> >> is more clear.
> >>
> >> The "if then" construct is really confusing.
> >> "if then" is a statement, not an expression.
> >
> >
> > Yes, and that's why to get the desired semantics it's more appropriate
> to use  if then else  rather than  iif()  etc.
> >
> > Please correct me if I'm wrong, but my understanding is that in all
> cases where parameters are passed to a procedure or function they are
> evaluated and placed on the stack before the code is called. However the
> if then else  statement never, under any circumstances, executes code in
> the untaken statement/block, and it is that which is the required behaviour
> for an "inline if" expression.
> >
> > If we want to organise it so that FPC can only evaluate function
> parameters when required, then it is necessary to implement ALGOL-60's
> "call by name" semantics, which were universally agreed to be deeply messy
> and perhaps not even what the standard authors intended.
>
> Compiler intrinsics are not necessarily subject to these rules. Take for
> example Assert: the string parameter whig can contain function calls is
> only evaluated if assertions are active at all and the condition is false.
> Same with the IfThen-intrinsic I had added, it only evalutes the branch
> that is taken.
> Please note that intrinsics are the exception, not the rule.
>
> Regards,
> Sven
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to