On 16 October 2011 08:16, Nick Coghlan <ncoghlan@gmail.com> wrote:
We may also decide to eliminate the "new scope" implications for 'given' statements entirely and focus solely on the "out of order execution" aspect. That would not only simplify the implementation, but also make for a cleaner extension to the compound statement headers.
FWIW, I did a quick review of some of my own code where I expected the given clause to be helpful (relatively mathematical code computing continued fractions - lots of complex expressions with subexpressions that can be factored out using throwaway names, and very few of the subexpressions are meaningful enough by themselves to make coming up with helpful names really viable). I was surprised to find that the in-line code, using a lot of x's and y's, was readable enough that I could find little use for the given clause. If the "new scope" semantics is included, I might have got some small benefits from being able to reuse x and y all over the place safe in the assurance that a typo wouldn't cause me to silently pick up the wrong value. But even that is stretching for benefits. I still like the idea in principle, but I'm no longer sure it's as useful in practice as I'd expected. A really good use case would help a lot (Nick's argparse example is a start, but I'm nervous about the idea of writing an API that relies on out of order evaluation to be readable). Paul.