Re: Re[2]: [fpc-pascal] some new features to delphi prisem

2010-02-22 Thread Matt Emson



Sent from my iPhone

On 21 Feb 2010, at 19:37, JoshyFun joshy...@gmail.com wrote:

z := iff(a=b,1,2);

But to me it looks awful and a bit of c-ism


No, that is a VB-ism. A C-ism would be:

z = (a==b ? 1 : 2);

Which I fo tend to use myself in c# as it is a lot more convenient in  
some cases. 
___

fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] some new features to delphi prisem

2010-02-21 Thread JoshyFun
Hello FPC-Pascal,

Sunday, February 21, 2010, 7:29:54 PM, you wrote:

MK This is a matter of taste, I can imagine uses when at least functional
MK if would make code *more* readable. Noone forces programmers to
MK convert all their case/if to functional versions if they look
MK unreadable. The functional variants are supposed to be used in
MK particular situations, when they make sense.

For me the bigger problem is that both statements change its behavior
in function of its context.

if a=b then 1 else 2;

this is a pascal error, but

z := if a=b then 1 else 2;

Is it correct ? From my point of view is much more reasonable to use
something like:

z := iff(a=b,1,2);

But to me it looks awful and a bit of c-ism and really horrible code
could be written:

z: Boolean;
begin
z := iff(a=b,iif(b=2,a=b,ba),not(a=b));

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] some new features to delphi prisem

2010-02-21 Thread JoshyFun
Hello FPC-Pascal,

Sunday, February 21, 2010, 9:32:50 PM, you wrote:

DWN This is actually valid ALGOL 60 and/or ALGOL 68.  Conditional
DWN expressions were available in both languages.  I think Niklaus Wirth
DWN continued with this in ALGOL W, but dropped it from Pascal.
DWN Note that the ALGOLs required the else clause, as does C today (see
DWN below).

I'm the opposite of an compilers expert, also never learned Algol,
modula, eiffel or non main-stream languages, except Forth. So I
known my opinion is not an expert opinion, just an opinion only.

After this preamble :) I must say that this is Pascal, not Algol ;)

 Is it correct ? From my point of view is much more reasonable to use
 something like:
 z := iff(a=b,1,2);
DWN This is over-punctuated Visual BASIC.  Yuck.

iff is valid in VB ? Just a coincidence, I was trying to note the
if-function.

 But to me it looks awful and a bit of c-ism and really horrible code
 could be written:
 z: Boolean;
 begin
 z := iff(a=b,iif(b=2,a=b,ba),not(a=b));
DWN Mega-yuck!!

I even do not know the result :)

DWN I can only infer that you don't write C.  The C equivalent is:

Oh yes, I write and wrote C/C++ that's the reason I hate such things,
like:

if (a=a++==a) {..}

It's a funny entertainment to try to know which exactly that condition
will execute.

DWNz = a == b ? 1 : 2;
DWN It's terse, but one gets used to it.

In near 20 years I was unable to find the reason and need of such
constructions, even when my first computer only have 3 Kb for source
code.

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal