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-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's actually

Re: if3 then else otherwise ...

2001-07-30 Thread Edward Peschko
On Mon, Jul 30, 2001 at 08:23:12PM -0500, David L. Nicol wrote: raptor wrote: 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

Re: if3 then else otherwise ...

2001-07-30 Thread Ted Ashton
Thus it was written in the epistle of Edward Peschko, Maybe call it if3 print do { if3($A cmp $B){ They're the same }{ $A is before $B }{ $B is before $A } };

Re: if3 then else otherwise ...

2001-07-30 Thread Edward Peschko
Ed, Why should it die a horrible death? It seems like something which could be pretty easily implemented: sub if3 ($) { return {$_[1]} unless $_[0]; return {$_[2]} if $_[0] 0; return {$_[3]}; } gives the functionality. A little more research (and perhaps a quick

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 and -1 is

Re: if3 then else otherwise ...

2001-07-30 Thread Ted Ashton
Thus it was written in the epistle of Edward Peschko, ok, never mind. I got the impression that this was a built-in function, ie: if3 goes along with = the same that ()? : goes along with if() else. I have no problem if it follows from prototypes. Maybe we could implement '??' along the

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

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 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 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 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

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 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. http://www.engr.umd.edu/~nsw/ench250/fortran1.htm#IFA

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 most of the people... I forgot about it already :) ? : :

RE: if then else otherwise ...

2001-07-29 Thread Sterin, Ilya
: 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

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 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-28 Thread Sterin, Ilya
What's the point, you can accomplish the same with if/elsif/else. Maybe I'm not understanding this correctly, but if (cond) {} elsif (cond) {} else {} Ilya -Original Message- From: raptor [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 28, 2001 9:35 AM To: [EMAIL PROTECTED]

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 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

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 the time I have to edit a perl script of other person