Mailinglisten-Archive |
eschmid wrote:
>
> On Thu, 9 Mar 2000, Hartmut Holzgraefe wrote:
>
> > Markus Dobel wrote:
> >
> > > genau wie solch haessliche sachen wie $a = (bedingung?blubb:suelz);
> >
> > was ist daran denn haesslich? doch wohl nur dass es keine
> > dreiwege-variante
> > ( >0; ==0 ; <0) giebt wie sie (vom hörensagen her) FORTRAN haben soll
>
> Das muss wohl ein sehr modernes FORTRAN gewesen sein. Bei FORTRAN IV und
> FORTRAN 77 war's jedenfalls nicht dabei.
> http://infosoc.uni-koeln.de/mailman/listinfo/php
aus dem aktuellen C/C++ Users Journal (5/2000, S.67):
[...]
One Construct from FORTRAN II that i sometimes miss
is the three-way IF statement:
IF (J - 3) 10,20,30
10 ...
20 ...
30 ...
The first line branches to statement 10 if J-3 is less than zero,
20 if it equals zero and 30 if it is greater than zero. To do the
same thing with a logical IF statement requires two IFs:
[...]
Now this probably doesn't look much worse than the original,
especially
if you don't read FORTRAN and are lost in the details. But if C had a
three-way if statement we could, when neccessary, write code like
this:
ifn (j-3) {
printf (" j is less than zero\n");
} elsez {
printf(" j equals zero\n");
} elsep {
printf(" j is greater than zero\n");
}
[...]
ok, die Dreiwegigkeit bezieht sich auf IF/if und nicht auf '?:'
aber ein
$str = (j)?"negativ":"null":"positiv";
wäre doch auch nett
(und in diesem Fall auch kein Problem von wegen Lesbarkeit/Obfuscation,
beim '?:' muß man eh immer genauer hinschaun, das wird auch durch ein
'?::' nicht mehr schlimmer ? )
php::bar PHP Wiki - Listenarchive