On Wed, Mar 07, 2007 at 11:35:41PM +0900, Martin DeMello wrote:
> On 3/7/07, 7stud 7stud <dolgun / excite.com> wrote:
> >Also, to be consistent, shouldn't it be:
> >
> >z = if x < y
> >  true
> >els
> >  false
> >end
> 
> Note the difference between
> 
> z = if x < y
>  -1
> else if x == y
>    0
>  else if x < y
>      1
>    end
>  end
> end
> 
> and
> 
> z = if x < y
>  -1
> elsif x == y
>   0
> elsif x < y
>   1
> end

Whitespace isn't significant.  No need to make it ugly like that.

. . . though I understand your point -- that it's logically nested.
Then again, that's kinda what's happening anyway -- you're nesting "if"
inside "else".  The use if elsif is just a linguistic convention that
some people find more helpful for understanding what's going on.

I suspect (though I don't know for sure, since I've never fully specced
out a language and implemented it) that using "else if" would even be
easier for the implementation, since there's one fewer keyword involved.
You'd just have to be sure to allow a "hidden" end keyword effect when
another else appears without an explicit end keyword.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Leon Festinger: "A man with a conviction is a hard man to change. Tell
him you disagree and he turns away. Show him facts and figures and he
questions your sources. Appeal to logic and he fails to see your point."