in ?:: or any other condition checking block, 0 is true, everything else is
false.  I am yet to see why otherwise or any third condition is needed.  If
that's then we can have 4 conditions 1,0,-1,undef, and we can keep going.
That is why there are conditions, if you want to check for -1 you must
specifically do it.

if($foo == 1)
{}
elsif ($foo == -1)
{}
elsif (!$foo)
{}
else
{}

given/when will of course decrease the amount of typing needed.

I know this is a dead issue, but I just can't see how some people actually
see the logic in having three conditions 1,0,-1.  What about -2, -3, etc...
The whole purpose in ?:: is to deferentiate between true or false, weather
it be 1|0 2|0, -1|0, doesn't matter is still true or false.

Ilya

> -----Original Message-----
> From: raptor [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, July 29, 2001 4:32 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: if then else otherwise ...
>
>
> > Linguistically, "if then else, otherwise" doesn't make sense,
> since 'else'
> > and 'otherwise' are synonymous.
> ]- ok .. I choosed wrong word... I'm not native English sorry...
> but I agree
> that if-else-otherwise construct is not so good, for most of the
> people... I
> forgot about it already :")
>
> > ? : : suffers from the same problem, just in terms of the ternary ?:
> > operator (which of course, wouldn't be ternary anymore) instead of
> English.
> > I'm not sure if there will be ambiguity where the standalone colon is
> being
> > used elsewhere, but I suspect that it would make parsing more difficult.
> > (At least in a BNF grammar.)
> ]- then may be some other way :
>
> cond ? then : else ~ otherwise;# i don't know
>
> > Regardless of how you perceive the results of <=> and cmp, it's
> still two
> > conditionals.  Something has to make the differentiation
> between positive
> > and negative.
> ]- we told trenary not boolean context... is trenary context ok ? we will
> have many more contexts in Perl 6.66 aren't we ];")::
>
> > You're simply asking for another way of writing 'if {} elsif {}
> else {}',
> > because you don't like 'elsif'.  Fine.  As has been said before, use a
> > switch.
> > Still too verbose?  Let's look at your example....
> >
> > > $whereCond =  $cond ? ' field > $x AND ' : '' : ' field < $x AND';
> > > $Query = qq{ SELECT .... FROM ... WHERE $whereCond ...};
> >
> > I think if you specify WHERE you need a clause.
> > 'SELECT foo FROM bar WHERE' doesn't make sense.
> ]- my mistake sorry. There is "..." if u see, so it is more specificaly :
>
>  $whereCond =  $cond ? ' field > $x AND ' : '' : ' field < $x AND';
>  $Query = qq{ SELECT .... FROM ... WHERE $whereCond field2 =
> (SELECT fieldX
> FROM blah WHERE fieldA = $id )};
>
> is this way ok....and this is just example, can figure out some
> other at the
> moment, but that is the reason I'm posting here to see all your
> opinions if
> it is worth it. If (not) I'm ok ( sorry for your time) else (then OK)
> otherwise (will see)  :")
>
> =====
> iVAN
> [EMAIL PROTECTED]
> =====
>
> PS. What type of query to build :
>
> $qtype = cond ? SELECT : INSERT : UPDATE;
>
> or I'm building a query for update or insert how to decide how the current
> key -> value pair will be used :
> this time we are deciding between  INSERT, UPDATE or UPDATE-WHERE clause :
>
> $kv .= $qtype ? do {$values .= "$v, ", "$k, "} : "$k = $v, " :
> "$k = $v AND
> ";#is this correct
>
> later :
> chop,chop...substr..!!
> $query = "INSERT INTO blah ( $kv ) VALUES ( $values )";
> OR
> $query = "UPDATE blah SET $kv WHERE something...";
> OR
> $query = "UPDATE ..something... WHERE $kv";
>
> More examples  :
> =============
> index(ref $var, 'A') - 1 ? SCALAR-LVALUE-case : HASH-case : ARRAY-case;
> i.e.
> index(ref $var) - 1 ? $v = $var : $v alias $var : @v = @$var;
>
> =============
> form-field-type ? <select> : <input> : <textarea>;
>
> =============
> output-type ? print-to-web <BR> : print-to-stdout \n : print-to-STDERR;
>
> =============
>
> $x = $a <=> $b ? $a : $default : $b;
>
> can figure out more at the moment :")

Reply via email to