Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding possibility to add bindings in debugger context interaction model #378

Conversation

adri09070
Copy link
Contributor

This is experimental code that will be used to add bindings in the debugger code presenters. This could be used to instrument code by manipulating objects from anywhere in Pharo, in order to debug something. I think this is quite in adequation with the "playground programming style" that Pharo has.

Notably, I would need this for Chest, which is a debugger extension that allows to store objects from anywhere in Pharo and to load them into any playground (or debugger if this PR is accepted): https://github.com/adri09070/Chest
In the end, we will try with @StevenCostiou to load any object from Chest in any method by annotating its AST

This is experimental code to be able to instrumente code by manipulating objects from anywhere in Pharo,  to debug something.
@MarcusDenker
Copy link
Contributor

Very interesting! We already had requests for that (for the inspector pane especially).

One thing we need to check if reading bindings from the workspace still works in the debugger:

  • open a playground
  • define a binding there "hello := 1"
  • open a debugger with "hello halt"
  • can we read the 'halt' variable still when we are in the debugger?

I should make an image with this...

@adri09070
Copy link
Contributor Author

I tried on my Chest image and, yes it works. In the code, I prioritize context variables over presenter variables.

A problem I've just discovered, though, is that you can't execute code in the debugger, except manually. Because, to do that, the method needs to be saved and asks to declare variables as temporary or instance variables, which is not what we want. And cancelling doesn't save the method, of course. Anyway, the goal is not to save the code as the added variables couldn't be accessed outside the debugger they were added in.

It's more complicated than I thought and maybe it's not worth devoting time to this until we have a version of that with metalinks to allow to add variables to the method AST instead of the presenter?

Comment on lines 39 to 41
(self hasBindingInInteractionModelOf: aString)
ifTrue: [ self bindings associationAt: aString ]
ifFalse: [ nil ] ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be simplified by something like

self bindings associationAt: aString ifAbsent:[nil]

?

Copy link
Contributor Author

@adri09070 adri09070 Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right.

We can replace

(self hasBindingInInteractionModelOf: aString)
 				  ifTrue: [ self bindings associationAt: aString ]
 				  ifFalse: [ nil ]

by

self bindings associationAt: aString ifAbsent:[nil]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@MarcusDenker MarcusDenker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good to add as, if the additionals bindings are not set, it should have no impact at all.

This is a good step, we already had a request for allowing workspace style bindings in the inspector evaluation pane, for example. And this would be a step to experiment with these things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants