Re: if3 then else otherwise ...
by Edward Peschko other posts by this author
Jul 31 2001 2:12AM messages near this date
Re: if3 then else otherwise ...
|
Re: if3 then else otherwise ...
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 like this :
> >
> > if (cond)
> > { }
> > else {}
> > otherwise {}
> >
> > i.e.
> > if cond == 1 then 'then-block'
> > if cond == 0 then 'else-block'
> > if cond == -1 then 'otherwise-block'
> >
> > If the "if" construct doesn't have "otherwise" it behave like the current
> > "if-else"..
>
> Just as any tree can be represented as a binary tree, any switch
> can be represented as a series of binary switches. In fact given current
> technology it must be so represented.
>
> So what you're talking about is a rewriting macro, you want to define
> a syntax
> raptorif($&&&)
> and have the language work out the details.
>
> Sounds okay to me; I wouldn't want to overload "if" in this way though.
> Maybe call it "if3"
>
> print do {
> if3($A cmp $B){
> "They're the same"
> }{
> "$A is before $B"
> }{
> "$B is before $A"
> } };
>
>
> I am reminded of the conditionals in TeX -- I think there is
> a three-lambda if that works this way -- not sure
> :)
guys... this idea should die a horrible death. It pretty much falls under the
'??' idea (which had far more merit than this IMO) which TOO died a horrid
death.
Ed
Thread:
raptor
David L. Nicol
David L. Nicol
Edward Peschko
Ted Ashton
Edward Peschko
Ted Ashton
Michael G Schwern
Sterin, Ilya
raptor
Sterin, Ilya
raptor
Bryan C. Warnock
Bart Lateur
Bryan C. Warnock
Sterin, Ilya
raptor
Bart Lateur
raptor
Bryan C. Warnock
raptor
Bart Lateur
John Porter
David Grove
John Porter
David Grove
|