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

Changing the provided Code may lead to unwanted behavior #7

Closed
LeonMatthes opened this issue Aug 14, 2018 · 2 comments
Closed

Changing the provided Code may lead to unwanted behavior #7

LeonMatthes opened this issue Aug 14, 2018 · 2 comments

Comments

@LeonMatthes
Copy link
Collaborator

LeonMatthes commented Aug 14, 2018

If you replace the Code that is provided by the MorphicTutorial and then evaluate the code, some strange behavior happens:

  • if you remove a provided variables declaration it is still defined at runtime, which is kind of weird, because it is no longer visible by the user
  • If you add new variables to an already provided variable declaration, these variable declarations will result in some very weird behavior, in which the code compiles and runs fine, but when you open the method it was compiled into, the variable declaration is missing, causing you to be unable to save the method again, because it contains an undeclared variable
  • if you change the method declaration in an exercise like "Swapping colors", it will compile the new method name into the ColorfulMorph, which is most of the time not what you want, especially as there is no warning or confirmation, it just silently compiles it, possibly leading to problems when rerunning the exercise later.

Possible fixes:

  1. Provide a warning if such user change is detected (possibly difficult to find every change, error prone)
  2. Lock down the text to not allow change by the user (may require an extra text field)
LeonMatthes added a commit that referenced this issue Aug 28, 2018
First try to implement the option of moving the first line of code into an extra text field.
As this would destroy the styling of the parameters, try to fix this by providing an extra Environment which includes the parameters (not working yet!)
@LeonMatthes
Copy link
Collaborator Author

Currently working on option 2.
Adding a second text field which is locked seems to be the best option at the moment.
This does however mess with the syntax highlighting., as the parameters of the Method/Workspace are no longer declared inside the text field. I am currently working on fixing this by creating a custom Environment for the TextStyler so that it at least recognizes the parameters as globals and not as errors.
This is not working yet, I am not sure why, therefore any help to why the changes made in commit cd3bbb6 don't work would be appreciated.

@LeonMatthes
Copy link
Collaborator Author

Maybe adding a specialisation of the Parser will help with this, as the Environment solution does not seem to work.
Will be working on this angle for the next days

LeonMatthes added a commit that referenced this issue Sep 1, 2018
Uses a custom parser for syntax highlighting.
Reuses the context bar for the method name/parameter list
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

No branches or pull requests

1 participant