Logo-small

4.3.3 Fixing Underscores

In Pharo, assignment should be declared using := (no more underscore).

Loading code with underscores

When loading code with underscores, the system will complain. There is a preference that allows you to silently load the code in the system.

To set it up:

  • Bring up the world menu
  • Select System, then Settings (for Pharo 1.1). You will get a nice setting browser,
  • Click on the Compiler item
  • Select "Allow underscore as assignment"

Fixing code with underscores with the Refactoring Browser

With the refactoring browser, the changes are done at the abstract syntax tree level to guarantee only assignments are changed.

1. Load the code:

 Gofer new
     squeaksource: 'rb';
     version: 'AST-Core-lr.67';
     version: 'Refactoring-Core-lr.122';
     load.

2. Select the code (packages) you want to fix:

  environment := BrowserEnvironment new
      forPackageNames: #('Connectors-Base' 'Connectors-Lines and Curves').

3. Create the transformation rule:

  rule := RBUnderscoreAssignmentRule new.

4. Perform the search:

  SmalllintChecker runRule: rule onEnvironment: environment.

5. Perform the transformation:

  change := CompositeRefactoryChange new.
  change changes: rule changes.
  change execute						

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |