From: "Mauricio Fernández" Date: 2002-10-08T19:02:05+09:00 Subject: Re: Specifying local and external block parameters (that old chestnut) On Tue, Oct 08, 2002 at 06:38:53PM +0900, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Specifying local and external block parameters (that old chestnut)" > on 02/10/08, Mauricio Fern�ndez writes: > > |i = 0 > |x = 'some value' > |(0...10).each do |i| > | x := 'surprise!' if i == 2 > | x = i # uses local after the := is run > |end > | > |x => 1 > | > |Having 'x = ...' meaning completely different things depending on the > |"execution context" makes me feel unsecure. > > They are not "completely different". Think about the following C > code: > > int foo() { > int a > a = 42; > printf("a=%d\n", a); > { > int a; > a = 55 > printf("a=%d\n", a); > } > printf("a=%d again\n", a); > } My concern is about the code meaning different things in _each iteration_; I'd expect the code in a for loop to always behave the same. > This is somewhat confusing but completely valid code in C. Besides, > in (future) Ruby, you will be warned for a bad style. > > matz. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com [...] or some clown changed the chips on a board and not its name. (Don't laugh! Look at the SMC etherpower for that.) -- from /usr/src/linux/MAINTAINERS