On 9/14/06, Philip Ganchev <[EMAIL PROTECTED]> wrote: > On 9/13/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote: > > A user on IRC recently suggested that it should be possible to specify > > what an end block actually ends, like: > > > > if false > > echo this never happens > > end if > > I'm not sure I understand the purpose of this feature. If it is to > make it clear which block the end-command ends, then why not use > block-specific end commands, like "fi" for "if", etc?
Because you shouldn't have to worry about this if you don't want to. Just use end as you always have. > > This feature makes the language more complicated, and so makes code > harder to read. To understand an if-statement that has an end > condition, I now have to remember to check not only its if-condition > but also the end-condition. I expect that more bugs will occur from > forgetting to check this, than the bugs avoided by it. No you don't. You don't have to change a single line of code. You simply have the _option_ of explicitly stating what a specific end block ends. In a 100-line code block that is nested five levels, this can be a very nice memory aid. You have always had the option of using something like if test .... ... end #if The only change is that with the new syntax, fish will actually make _sure_ that you aren't lying. > > Even the fact that a block can end in more than one way would make > code harder to read; for example if both ``end'' and ``fi'' end an > if-block. It is better to choose one and stick to it. Absolutely. I don't consider that an option. One way of doing things... > > > > This would be caught before trying to execute the file/command: > > > > if true > > echo nor will this > > end begin > > So the ``echo`` command is not executed and the status after executing > the ``if`` block is 1? Does this signal a syntax error? Does it keep > the expression on the command line, as when you enter, say > > if true; echo nor will this; > Yes. > > > While this loop will execute _once_ after which time the end command will > > fail: > > > > for i in 1 2 3; echo $i; end (echo no) > > Why doesn't it do the same as with the ``if`` block when the end > condition fails, namley to fail before executing the body? Because in my opinion it would be very confusing if the end command executed before the contents of the loop. -- Axel ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
