Elseif?

Hi,

I just happend to find out that the “elseif” in ruby is spelled as
"elsif". Can anyone, probably Matz, tell me if there’s any "historical"
reason? :slight_smile:

Shannon

I just happend to find out that the “elseif” in ruby is spelled as
“elsif”. Can anyone, probably Matz, tell me if there’s any
“historical” reason? :slight_smile:

It’s spelt that way in Perl. Not sure if Perl nicked it from anywhere.
Most shells seem to use ‘elif’.

Of course, in C there is no ‘else if’, just an interesting set of syntax
rules that permit it to look like there is =)

cheers,

···


Iain.

Hi,

I just happend to find out that the “elseif” in ruby is spelled as
“elsif”. Can anyone, probably Matz, tell me if there’s any “historical”
reason? :slight_smile:

Shannon

Well, it’s not the first language to do so, so there’s a historical reason.
“Elseif” isn’t a real word any more than “elsif”, so it doesn’t bother me.

Gavin

···

From: “Shannon Fang” xrfang@hotmail.com

Hi,

···

In message “elseif?” on 02/12/05, Shannon Fang xrfang@hotmail.com writes:

I just happend to find out that the “elseif” in ruby is spelled as
“elsif”. Can anyone, probably Matz, tell me if there’s any “historical”
reason? :slight_smile:

Syntax did not allow “else if”. So I chose the shortest same pronounce
word.

						matz.

Hi, I just happend to find out that the “elseif” in ruby
is spelled as “elsif”. Can anyone, probably Matz, tell me
if there’s any “historical” reason? :slight_smile:

That was the thing I found most jarring about Ruby, too. Not being a
Perl programmer, “elsif” violated the principal of least surprise for
me. As I said in a post here a couple of months ago, I think it’s a
human factors issue. I understand all the Perl’ers and old Ruby hands
wanting to keep “elsif”, but since it doesn’t conflict with anything I
wish “elseif” would be added as an alternate syntax. After all,
there’s more than one way to do lots of other things in Ruby, and
that’s a good thing!

–paul

I just happend to find out that the “elseif” in ruby is spelled as
“elsif”. Can anyone, probably Matz, tell me if there’s any
“historical” reason? :slight_smile:

It’s spelt that way in Perl. Not sure if Perl nicked it from anywhere.
Most shells seem to use ‘elif’.

It’s a bad thing to inherit or borrow… Since ruby support both && and

or, why not support both elsif and elseif? Just a suggestion

Shannon

It seems like every language makes a different choice in this matter.
I’ve seen all of the following in various different languages…

else if
elseif
elsif
elif

I can never remember which variation goes with which language. If I
recall correctly, Eiffel changed from on spelling to another, making it
very interesting to type in code from an older tutorial and finding
syntax errors.

I’m for leaving this one alone in Ruby.

···

On Thu, 2002-12-05 at 00:53, Paul J. Sanchez wrote:

> Hi, I just happend to find out that the "elseif" in ruby
> is spelled as "elsif". Can anyone, probably Matz, tell me
> if there's any "historical" reason? :)

That was the thing I found most jarring about Ruby, too. Not being a
Perl programmer, “elsif” violated the principal of least surprise for
me.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

  • Iain wrote:
    [ snip regarding where ‘elsif’ came from ]

It’s spelt that way in Perl. Not sure if Perl nicked it from
anywhere. Most shells seem to use ‘elif’.

It’s a bad thing to inherit or borrow…

Why? Ruby has borrowed many perlisms. Just look at the regex support and
surrounding variables =)

Half of the attractiveness of Ruby to me is that it’s much like Perl,
but easier and with less typing.

Since ruby support both && and || or, why not support both elsif and
elseif? Just a suggestion

Perl also supports ‘&&’ and ‘and’, and ‘||’ and ‘or’. I imagine that’s
also where Matz borrowed those =)

The thing to note about those is that they have different precedence.
‘&&’ is not directly synonymous with ‘and’. ‘and’ has ultra-low
precedence, thus obviating the need for parentheses in many cases.

Having elsif/elif/elseif/‘else if’ all be the same would be somewhat
pointless.

Mind you, I’m still somewhat irritated that Proc and def are so
dissimilar to each other. But I’ll live =)

cheers,

···


Iain.

Well easy to learn and easy to read is most important reason I like ruby.
That’s why I am hypersensitive about the funny symbols. I would again
express my thanks to Gavin, and all rubyists here to help me understand
funny symbols and Symbol class.

I don’t think you should attribute regex to perl. I love regex, but it
is not a perl thing. I use grep and vim… all support regex. About
other stuff like $_ $! $` … I hate them. Probably using english.rb
is better?

Shannon

···

On Thu, 5 Dec 2002 08:50:55 +0900 Iain ‘Spoon’ Truskett spoon@dellah.org wrote:

  • Iain wrote:
    [ snip regarding where ‘elsif’ came from ]

It’s spelt that way in Perl. Not sure if Perl nicked it from
anywhere. Most shells seem to use ‘elif’.

It’s a bad thing to inherit or borrow…

Why? Ruby has borrowed many perlisms. Just look at the regex support and
surrounding variables =)

Half of the attractiveness of Ruby to me is that it’s much like Perl,
but easier and with less typing.

Since ruby support both && and || or, why not support both elsif and
elseif? Just a suggestion

Perl also supports ‘&&’ and ‘and’, and ‘||’ and ‘or’. I imagine that’s
also where Matz borrowed those =)

The thing to note about those is that they have different precedence.
‘&&’ is not directly synonymous with ‘and’. ‘and’ has ultra-low
precedence, thus obviating the need for parentheses in many cases.

Having elsif/elif/elseif/‘else if’ all be the same would be somewhat
pointless.

Mind you, I’m still somewhat irritated that Proc and def are so
dissimilar to each other. But I’ll live =)

cheers,

Iain.

And here I thought that Ruby had stronger typing than Perl :slight_smile:

martin

···

Iain ‘Spoon’ Truskett spoon@dellah.org wrote:

Half of the attractiveness of Ruby to me is that it’s much like Perl,
but easier and with less typing.A

The only $ symbols I regularly use are $1…$9 (and very
rarely $’ and $`) – you could use English.rb for the rest, but instead
I’d recommend trying a coding style that just doesn’t need them.
Whenever you find yourself using one of them, treat it as a warning
flag, and ask if perhaps there’s an alternative.

Dave

···

On Wed, 2002-12-04 at 18:11, Shannon Fang wrote:

Aboutother stuff like $_ $! $` … I hate them. Probably
using english.rb is better?

[…]

I don’t think you should attribute regex to perl. I love regex, but it
is not a perl thing. I use grep and vim… all support regex.

It is a perl thing: Native regex support in the language.

One reason I’ve not bothered looking at the xregex package someone
posted was because it uses strings rather than regexes. I’d much rather
see xregex posted as a patch to the ruby sources to improve all regexen.

About other stuff like $_ $! $` … I hate them. Probably using
english.rb is better?

I was mostly thinking $1, $2, $3 …

While it would be good using the long names of the punctuation ones,
sometimes that’s just irritating. I’m not a Java/VB programmer =)

For me, writing unnecessary code is what makes a programming language
bad. Thus Perl loses points in the OO department, while Ruby gives
several thousand. Ruby lets me do things quickly and simply.

I use $1… rather than fiddling with match objects. Does that make me a
bad ruby programmer? =)

I think we’re just disagreeing about how ruby is so lovely =)

cheers,

···


Iain.

[…]

I don’t think you should attribute regex to perl. I love regex, but it
is not a perl thing. I use grep and vim… all support regex.

It is a perl thing: Native regex support in the language.

How about awk? :wink: I guess it was a pioneer in “Native regex support in
the language”.

···

----- Original Message -----
From: “Iain ‘Spoon’ Truskett” spoon@dellah.org
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, December 04, 2002 4:26 PM
Subject: Re: elseif?

One reason I’ve not bothered looking at the xregex package someone
posted was because it uses strings rather than regexes. I’d much rather
see xregex posted as a patch to the ruby sources to improve all regexen.

About other stuff like $_ $! $` … I hate them. Probably using
english.rb is better?

I was mostly thinking $1, $2, $3 …

While it would be good using the long names of the punctuation ones,
sometimes that’s just irritating. I’m not a Java/VB programmer =)

For me, writing unnecessary code is what makes a programming language
bad. Thus Perl loses points in the OO department, while Ruby gives
several thousand. Ruby lets me do things quickly and simply.

I use $1… rather than fiddling with match objects. Does that make me a
bad ruby programmer? =)

I think we’re just disagreeing about how ruby is so lovely =)

cheers,

Iain.

I might look at that once the feature list is finalised, though I’m
uncomfortable patching the Ruby source. I’d much rather keep it pure
Ruby. I agree, though, that having to use strings is a very annoying
feature.

martin

···

Iain ‘Spoon’ Truskett spoon@dellah.org wrote:

One reason I’ve not bothered looking at the xregex package someone
posted was because it uses strings rather than regexes. I’d much rather
see xregex posted as a patch to the ruby sources to improve all regexen.

From: “Iain ‘Spoon’ Truskett” spoon@dellah.org
[…]

It is a perl thing: Native regex support in the language.

How about awk? :wink: I guess it was a pioneer in “Native regex support
in the language”.

Point conceded. =)

I tend to forget about awk =)

(fwiw on a semi-unrelated note, my emphases were to take note that I was
talking about languages and not tools, and it being intrinsic rather
than a bolton; although it should be noted that vim does support regexes
in its support language).

cheers,

···


Iain.