Yuval Kogman skribis 2005-09-20 20:33 (+0300): > Today on #perl6 I complained about the fact that this is always > inelegant: > if ($condition) { pre } > unconditional midsection; > if ($condition) { post }
I believe it's not inelegant enough to do something about. The unconditional part is easily copied if it's a single line, and can easily be factored to a method or sub if it's not. Especially with lexical subs. my sub midsection { unconditional midsection; } if ($condition) { pre; midsection; post; } else { midsection; } Although the original you show isn't so bad either. It gets bad when $condition gets complex, but in that case, you should use a named variable for documentation anyway. I think your proposed feature makes cluttered and eventually even less elegant programming way too easy and attractive, and that its benefits are far too little. At first glances, it makes me think it's mostly useful for people who hate refactoring. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html