From: Konrad Meyer Date: 2007-09-09T12:40:41+09:00 Subject: Re: Bug in lambda? --nextPart1899898.QzmCiarhaQ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Saturday 08 September 2007 08:15:06 pm kevin cline wrote: > This looks like a pretty serious bug. It seems that lambda- > expressions are not properly localizing their formal arguments: >=20 > bash-3.2$ ruby --version > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] >=20 > bash-3.2$ cat lambda-bug.rb > a =3D 0 > f =3D lambda { |a| a } > puts "a =3D #{a}" > puts "f.call(1) =3D> #{f.call(1)}" > puts "now a =3D #{a}" >=20 > bash-3.2$ ruby lambda-bug.rb > a =3D 0 > f.call(1) =3D> 1 > now a =3D 1 IIRC this is a ruby 1.8.x thing; it will be fixed in 1.9. Don't depend on this behaviour / try to avoid repeating variable names :D. Cheers, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart1899898.QzmCiarhaQ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBG42spCHB0oCiR2cwRAh39AKCa05rnHzYjy3vN3jxL1EmcJQgZwACfflUt j9FAxqouw3riaCDpxasqcKQ= =U/zC -----END PGP SIGNATURE----- --nextPart1899898.QzmCiarhaQ--