[CMake] elseif request

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Sep 16 16:39:57 EDT 2006


My proposal was

if(cond1)
   block of statements
elseif(cond2)
   block of statements
elseif(cond3)
   block of statements

...

elseif(condn)
   block of statements
else(cond1)
   block of statements
endif(cond1)

I should have clarified that proposal was to replace the the following
equivalent that currently exists in the language:

if(cond1)
   block of statements
else(cond1)
   if(cond2)
     block of statements
   else(cond2)
     if(cond3)
       block of statements
     else(cond3)
...
           else(condn-1)
             if(condn)
               block of statements
             else(condn)
               block of statements
             endif(condn)
           endif(condn-1)
...

     endif(cond3)
   endif(cond2)
endif(cond1)

So all the proposed "elseif" command does is provide some syntactical sugar
in a form very close to what most other languages have.

On 2006-09-16 12:11-0700 Brandon J. Van Every wrote:
> It is the CMake language style to force the user to 
> bracket their conditional with matching conditions.  Personally I think this 
> is a good design choice, especially as conditionals are nested deeper and 
> deeper, as it does prevent some user errors.

Correct me if I am wrong, but here is what I assume you are proposing.

if(cond1)
   block of statements
elseif(cond2)
   block of statements
endelseif(cond2)
elseif(cond3)
   block of statements
endelseif(cond3)

...

elseif(condn)
   block of statements
endelseif(condn)
else(cond1)
   block of statements
endif(cond1)

To my mind those additional endelseif statements in this alternative
proposal go against the whole reason for my first proposal which is to
reduce the clutter that occurs in the equivalent existing form now present
in the language. Also, demanding those extra endelseif statements will
confuse lots of programmers who are used to something very close to my
original proposal for all other languages.  So my order of preference is (1)
my original proposal, (2) the status quo, and (last) the alternative
proposal you seem to be advocating.

What do others here think?  If after discussion there is strong support for
my proposal (or any other that reduces clutter for if blocks in a way that
is as consistent as possible with what other languages do), then I will be
happy to make the appropriate wish-list bug report.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list