mirror of
https://github.com/pharo-project/pharo.git
synced 2026-06-03 22:24:10 +00:00
Page:
XX PhIP Requestor Variables
Pages
01 PhIP Simplify Pragma Storage
02 PhIP Undeclared Variables
03 PhIP Cleanup ProtocolOrganizer ClassOrganization
04 PhIP ReparseAfterSourceEditing Cleanup
05 PhIO MicrodownForDocs
Contribute a fix to Pharo
Full Blocks
GitHub Project Boards
Home
Issue Tracker Bots
Low Hanging Fruits
Pharo Improvement Proposals
Project Ideas
XX PhIP Code MetaData
XX PhIP CompiledMethod Flags
XX PhIP Object Logger
XX PhIP RPackage
XX PhIP Requestor Variables
No results
4
XX PhIP Requestor Variables
Marcus Denker edited this page 2021-06-30 13:36:02 +02:00
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)