Re: if then else otherwise ...

2001-07-30 Thread Michael G Schwern
On Sat, Jul 28, 2001 at 04:34:46PM +0300, raptor wrote: > if (cond) > { } > else {} > otherwise {} > > > i.e. > if cond == 1 then 'then-block' > if cond == 0 then 'else-block' > if cond == -1 then 'otherwise-block' Sounds like you need a switch, yes. The cases where "cond" will be 1, 0 a

Re: if then else otherwise ...

2001-07-30 Thread Bryan C . Warnock
On Monday 30 July 2001 07:29 am, Bart Lateur wrote: > On Sun, 29 Jul 2001 19:36:43 -0400, Bryan C. Warnock wrote: > >$x = ($default,$a,$b)[$b<=>$a]; # Much like I did before > > Note that > > $x = cond? a : b > > does lazy evaluation, i.e. the value for a or for b is only fetched when > it'

Re: if then else otherwise ...

2001-07-30 Thread Bart Lateur
On Sun, 29 Jul 2001 19:36:43 -0400, Bryan C. Warnock wrote: >$x = ($default,$a,$b)[$b<=>$a]; # Much like I did before Note that $x = cond? a : b does lazy evaluation, i.e. the value for a or for b is only fetched when it's actually needed. In your construct, they're all fetched anyway

Re: if then else otherwise ...

2001-07-29 Thread raptor
> 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

Re: if then else otherwise ...

2001-07-29 Thread Bryan C . Warnock
On Sunday 29 July 2001 04:32 pm, raptor wrote: > index(ref $var, 'A') - 1 ? SCALAR-LVALUE-case : HASH-case : ARRAY-case; That one is actually rather clever Most of your examples, however, look like you are attempting to bandage some poorly designed code upstream. (Perhaps not, but writing

RE: if then else otherwise ...

2001-07-29 Thread Sterin, Ilya
ROTECTED]; [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 nat

Re: if then else otherwise ...

2001-07-29 Thread raptor
> 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 m

Re: if then else otherwise ...

2001-07-29 Thread Bart Lateur
On Sun, 29 Jul 2001 18:08:00 +0300, raptor wrote: >But at least the second shortcut is worth it, i think : >> >>cond ? then : else : otherwise > >This has a vague smell of Fortran. > >]- I don't know Fortran sorry :") Then check this out.

Re: if then else otherwise ...

2001-07-29 Thread Bryan C . Warnock
Linguistically, "if then else, otherwise" doesn't make sense, since 'else' and 'otherwise' are synonymous. ? : : suffers from the same problem, just in terms of the ternary ?: operator (which of course, wouldn't be ternary anymore) instead of English.

FW: if then else otherwise ...

2001-07-29 Thread Brent Dax
# This makes no sense. ?: tests a boolean value, which is either true or false. # There is no ternary state for a boolean value. True/False, Yes/No, On/Off, # 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False? No. He's effectively saying this: condition ? executed-if-po

Re: if then else otherwise ...

2001-07-29 Thread raptor
But at least the second shortcut is worth it, i think : > >cond ? then : else : otherwise This has a vague smell of Fortran. ]- I don't know Fortran sorry :") = iVAN [EMAIL PROTECTED] =

Re: if then else otherwise ...

2001-07-29 Thread raptor
> This makes no sense. ?: tests a boolean value, which is either true or false. > There is no ternary state for a boolean value. True/False, Yes/No, On/Off, > 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False? ]- I'm not talking about boolean's... but mostly this can be r

Re: if then else otherwise ...

2001-07-29 Thread John Porter
Bart Lateur wrote: > This has a vague smell of Fortran. Nothing vague about it. It is exactly analogous to Fortran's three-way if. -- John Porter

Re: if then else otherwise ...

2001-07-29 Thread John Porter
David Grove wrote: > There is no ternary state for a boolean value. True/False, Yes/No, On/Off, > 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False? He's suggesting True/False/-True (as in, 1/0/-1, which is what you get from cmp and <=>). How hard is that to understant?

Re: if then else otherwise ...

2001-07-29 Thread Bart Lateur
On Sun, 29 Jul 2001 14:22:23 +0300, raptor wrote: >But at least the second shortcut is worth it, i think : > >cond ? then : else : otherwise This has a vague smell of Fortran. -- Bart.

Re: if then else otherwise ...

2001-07-29 Thread David Grove
This makes no sense. ?: tests a boolean value, which is either true or false. There is no ternary state for a boolean value. True/False, Yes/No, On/Off, 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False? Doesn't matter. What you're asking has no counterpart in boolean l

Re: if then else otherwise ...

2001-07-29 Thread raptor
> I'm lost. How would you decrease the number of elsif statements with > otherwise??? ]- it is not to decrease the number of "elsif" (this that i hate elsif was just comment :") not that u have to stop using it ), but to give a shortcut ... ok forget about "otherwise" ( i also think no one will

RE: if then else otherwise ...

2001-07-28 Thread Sterin, Ilya
> -Original Message- > From: raptor [mailto:[EMAIL PROTECTED]] > Sent: Saturday, July 28, 2001 12:32 PM > To: Sterin, Ilya; [EMAIL PROTECTED] > Subject: Re: if then else otherwise ... > > > I've/m never used/ing "elseif" ( i hate it :") from

Re: if then else otherwise ...

2001-07-28 Thread David Grove
Oh boo hoo. Might I suggest a good introductory Perl book? p On Saturday 28 July 2001 12:32, raptor wrote: > I've/m never used/ing "elseif" ( i hate it :") from the time I have to > edit a perl script of other person that had 25 pages non-stop if-elsif > sequence) ... never mind there is two c

Re: if then else otherwise ...

2001-07-28 Thread raptor
I've/m never used/ing "elseif" ( i hate it :") from the time I have to edit a perl script of other person that had 25 pages non-stop if-elsif sequence) ... never mind there is two conditions in your example... of coruse i've think of this just like a shortcut nothing special ... later on : $x =

RE: if then else otherwise ...

2001-07-28 Thread Sterin, Ilya
; To: [EMAIL PROTECTED] > Subject: if then else otherwise ... > > > hi, > > we have <=> and 'cmp' operators but we don't have the conditional > constroct > to use better their result : > May be forthcomming switch will solve this in some way, but isn&#

if then else otherwise ...

2001-07-28 Thread raptor
hi, we have <=> and 'cmp' operators but we don't have the conditional constroct to use better their result : May be forthcomming switch will solve this in some way, but isn't it better to have shortcut like this : if (cond) { } else {} otherwise {} i.e. if cond == 1 then 'then-block' if cond