[Pharo-dev] Is variable shadowing a feature or a bug?

Marcus Denker marcus.denker at inria.fr
Fri Dec 13 02:32:30 EST 2013


On 12 Dec 2013, at 20:22, Frank Shearar <frank.shearar at gmail.com> wrote:

> On 12 December 2013 19:04, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>> 
>> 
>> 
>> On Thu, Dec 12, 2013 at 7:03 AM, Marcus Denker <marcus.denker at inria.fr>
>> wrote:
>>> 
>>> 
>>> On 12 Dec 2013, at 15:44, Benjamin <benjamin.vanryseghem.pharo at gmail.com>
>>> wrote:
>>> 
>>>> I just discovered that in Pharo 3 you can do:
>>>> 
>>>> [ :bool |
>>>>      self logCr: bool.
>>>>      bool := false.
>>>>      self logCr: bool.
>>>>      ] value: true
>>>> 
>>>> Is this a bug or a feature ?
>>> 
>>> 
>>> https://pharo.fogbugz.com/f/cases/12419/block-arguments-should-be-read-only
>> 
>> 
>> except that it didn't used to be a bug pre closures, so *if* its important
>> to be able to load old code this should be made a preference which is by
>> default on.  i.e. by default assigning to any argument is an error, but the
>> preference can be set to allow assignments to block args.  At least IIRC
>> that's how it is in Squeak right now.
> 
> It is: "Allow block argument assignment", or Scanner >>
> #allowBlockArgumentAssignment, depending on where you look.
> 

Ok, I will do it with the Preference

But in the long run, one can get rid of these things… e,g,

Step one: code critic rule to detect these cases
two: deprecate the code 
three: remove.

Marcus



More information about the Pharo-dev mailing list