[squeak-dev] The Trunk: Tools-eem.1064.mcz

Eliot Miranda eliot.miranda at gmail.com
Wed Sep 8 23:32:51 UTC 2021


Hi Christoph,

On Wed, Sep 8, 2021 at 5:27 AM Thiede, Christoph <
Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:

> In this case, the shadows were actually kind of intended because the field
> blocks should never refer to the receiver instance ...
>
> Not sure how we can ensure this otherwise. At least we have tests for the
> "copy expression" feature which depends on this invariant.
>

The only issue here is that if a method or block argument or temporary has
the same name as an instance variable then a warning is printed to the
transcript when the method is recompiled.  We should try and eliminate such
warnings.  So certainly in trunk code we should avoid shadowing variable
names.  The code itself is fine; the intent is fine.  My patch is only
intended to avoid the warning.  Ideally on recompiling the entire trunk
system we would see no such warnings.

>
> Best,
>
> Christoph
> ------------------------------
> *Von:* Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im
> Auftrag von commits at source.squeak.org <commits at source.squeak.org>
> *Gesendet:* Mittwoch, 8. September 2021 05:38:07
> *An:* squeak-dev at lists.squeakfoundation.org;
> packages at lists.squeakfoundation.org
> *Betreff:* [squeak-dev] The Trunk: Tools-eem.1064.mcz
>
> Eliot Miranda uploaded a new version of Tools to project The Trunk:
> http://source.squeak.org/trunk/Tools-eem.1064.mcz
>
> ==================== Summary ====================
>
> Name: Tools-eem.1064
> Author: eem
> Time: 7 September 2021, 8:38:04.292324 pm
> UUID: 2544ee88-6941-42d9-bc13-e3b384fb4708
> Ancestors: Tools-ul.1063
>
> Fix some shadowed inst var warnings in the inspector; 'object' is an inst
> var name but was used as a block arg name in a few methods.
>
> =============== Diff against Tools-ul.1063 ===============
>
> Item was changed:
>   ----- Method: BasicInspector>>fieldSelf (in category 'fields') -----
>   fieldSelf
>
>          ^ (self newFieldForType: #self key: #self)
>                  name: 'self'; emphasizeName;
> +                valueGetter: [:obj | self basicObjectPrintString];
> printValueAsIs;
> -                valueGetter: [:object | self basicObjectPrintString];
> printValueAsIs;
>                  valueGetterExpression: 'self';
> +                valueSetter: [:obj :value | self object: value];  "Switch
> to another object-under-inspection."
> -                valueSetter: [:object :value | self object: value];
> "Switch to another object-under-inspection."
>                  yourself!
>
> Item was changed:
>   ----- Method: BasicInspector>>streamInstanceVariablesOn: (in category
> 'fields - streaming') -----
>   streamInstanceVariablesOn: aStream
>
>          | attributesForInstVars |
>          attributesForInstVars :=  (UserInterfaceTheme current get:
> #instVar for: #SHTextStylerST80) ifNil: [#()].
>
>          (thisContext objectClass: self object) allInstVarNames
> withIndexDo: [:name :index |
>                  aStream nextPut: ((self newFieldForType: #instVar key:
> name)
>                          name: name; styleName: attributesForInstVars;
> +                        valueGetter: [:obj | thisContext object: obj
> instVarAt: index];
> -                        valueGetter: [:object | thisContext object:
> object instVarAt: index];
>                          valueGetterExpression: ('thisContext object: {1}
> instVarAt: {2}' format: { 'self'. index });
> +                        valueSetter: [:obj :value | thisContext object:
> obj instVarAt: index put: value];
> -                        valueSetter: [:object :value | thisContext
> object: object instVarAt: index put: value];
>                          yourself)].!
>
> Item was changed:
>   ----- Method: Inspector>>fieldAllInstVars (in category 'fields') -----
>   fieldAllInstVars
>
>          ^ (self newFieldForType: #all key: #allInstVars)
>                  name: self allInstVarsTranslated; emphasizeName;
> +                valueGetter: [:obj | obj longPrintString]; printValueAsIs;
> -                valueGetter: [:object | object longPrintString];
> printValueAsIs;
>                  yourself!
>
> Item was changed:
>   ----- Method: Inspector>>fieldSelf (in category 'fields') -----
>   fieldSelf
>
>          ^ (self newFieldForType: #self key: #self)
>                  name: 'self'; styleName: ((UserInterfaceTheme current
> get: #self for: #SHTextStylerST80) ifNil: [#()]);
> +                valueGetter: [:obj | obj];
> +                valueSetter: [:obj :value | self object: value]; "Switch
> to another object-under-inspection."
> -                valueGetter: [:object | object];
> -                valueSetter: [:object :value | self object: value];
> "Switch to another object-under-inspection."
>                  yourself!
>
> Item was changed:
>   ----- Method: Inspector>>streamInstanceVariablesOn: (in category 'fields
> - streaming') -----
>   streamInstanceVariablesOn: aStream
>
>          | attributesForInstVars |
>          attributesForInstVars :=  (UserInterfaceTheme current get:
> #instVar for: #SHTextStylerST80) ifNil: [#()].
>
>          (self object perform: #class "do not inline send of #class,
> receiver could be a proxy") allInstVarNames withIndexDo: [:name :index
> |
>                  aStream nextPut: ((self newFieldForType: #instVar key:
> name)
>                          name: name; styleName: attributesForInstVars;
> +                        valueGetter: [:obj | obj instVarNamed: name];
> +                        valueSetter: [:obj :value | obj instVarNamed:
> name put: value];
> -                        valueGetter: [:object | object instVarNamed:
> name];
> -                        valueSetter: [:object :value | object
> instVarNamed: name put: value];
>                          yourself)].!
>
>
>
>

-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210908/00073336/attachment.html>


More information about the Squeak-dev mailing list