Skip to content

XX PhIP Requestor Variables

Marcus Denker edited this page Jun 30, 2021 · 4 revisions

What is the current state?

When assigning a variable that starts with a lower case letter, the compiler will automatically add a binding to the requestor.

How is this implemented?

sending #lookupVar: to a RequestorScope creates the binding in the requestor (the tool) silently.

Why is this bad?

  • The mechanism is hidden. It happens without feedback from the programmer. A typo thus can lead to a new binding instead of a warning. Beginners might not be aware at all of the concept.
  • We can not create Global bindings.
  • Code complexity: as asking for a variable will create the binding, we need two methods for variable lookup: one that creates a binding, one that does not. -- hard to understand: asking if a variable exists --> no creation, #lookupVar:, does create. Has led to bugs in the past. -- hard coded logic. E.g. we check for uppercase in the variable lookup of the RequestorScope

What can we do instead?

  • The workspace could just show the undeclared variable with a gutter icon that allows a repair action.
  • With Undeclared Variables in Pharo10, we will force user interaction on assign --> This would allow us to open a fixed dialog at execution

The repair action then would be the same that we use for other undeclared variables.

  • The fixing code should ask the outer scopes if they can provide a definition --> this would allow to define global and shared vars, too.

Related PHiPs

  • 02-PhIP-Undeclared-Variables: will improve Undeclared Variables to raise repair actions at runtime (e.g. when executing DoIs in the Playground)