Re: inconsistencies with __return ejector
"Mark Miller" <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Mar 23, 2008 at 1:05 PM, Toby Murray <[email protected]> wrote: > I can't see why programmers would ever expect not to be able to use > return, especially if they come from an imperative (e.g. OO) > programming background, as so many of us do. In the code: def foo(flag) { def x := if (flag) { return 3 } else { 4 } return x * 2 } what should foo(true) return? How about foo(false)? If you easily answered 3 and 8, then you were not surprised that * the "return" inside the then-block returns from foo and not from the then-block * the 4 leaked from the else-block despite the lack of any further annotation. > Given that you can't make everyone happy, then it might be best to > go with a less subjective measure, rather than "expectations". > "Consistency" is perhaps a good objective test to apply here. People may > be unhappy but if the behaviour is consistent, then it's easier to > justify. Yes, that's how we arrived at the current behaviors: treat when-blocks like then-blocks and else-blocks. -- Text by me above is hereby placed in the public domain Cheers, --MarkM