"elseif" vs "else if"

stella's picture
public
stella - Fri, 2008-07-18 20:31

In the latest code review done by chx and Morbus at http://www.drupaltoughlove.com, one of the items commented on was the usage of "else if" instead of "elseif". There's nothing in the Coding Standards doc that specifically states that one should be used over the other, however it is "implied" from the first example on indentation that "elseif" should be used. Can the Coding Standards doc be updated so that it states one way or the other? Personally I don't mind which, but I would prefer if there was consistency. Core itself has a mixture, but with a higher number of "elseif".

An issue on this has already been raised at http://drupal.org/node/282405

Cheers,
Stella


:)

sun's picture
sun - Fri, 2008-07-18 22:10

I'm glad I'm not the only one who was surprised of this statement.

Personally, I prefer else if, because I find it easier to read, but I also think it doesn't matter at all.

Daniel F. Kudwien
unleashed mind


Some lenguajes don't support elseif

markus_petrux - Sat, 2008-07-19 07:21

So I'm in favor of else if for that reason. :-)

"Some languages don't

Morbus Iff@drup... - Sat, 2008-07-19 12:15

"Some languages don't support elseif?" I'm not entirely sure what that means. The only language we need to worry about supporting is PHP. The PHP documentation defaults to using elseif. PEAR defaults to using elseif. There are downsides for using "else if" (such as the colon variant, described in the linked issue). "elseif" is one word, compared to "else if", which would make it the only two word syntax in all of Drupal (and in all of PHP).

It just means I believe it's easier to remind one form

markus_petrux - Sat, 2008-07-19 13:26

It just means I believe it's easier to remind one form than two depending on the languaje being used. With Drupal it's easy to write PHP and Javascript almost at the same time, for instance. But anyway, there are other differences to take into account (ie. boolean constants, null, etc) so it is not that important another difference after all.