Comments (3)
The reason that the drawable observables were not previously forgotten is this:
(1) forget and forgetAll will refuse to forget a symbol that is referenced by another symbol unless that other symbol is also being simultaneously forgotten using forgetAll. This is specified by the description of forget in the EDEN handbook.
(2) picture has some system-defined stuff attached to it in order to ensure that the canvas gets redrawn when the value of picture changes. forgetAll won't delete stuff marked as system. Therefore, because you can't delete the system-defined canvas behaviour you couldn't forget picture and therefore you couldn't forget anything referenced by picture.
This raises other issues more generally about what should happen when an observable linked to a view is forgotten.
forget and forgetAll return information about which symbols could and could not be forgotten and the reasons why. See the EDEN handbook for information about the possible return values for forget, and the JS-EDEN source code for information about forgetAll*.
I have now changed the behaviour to the following:
(1) Attempting to perform a forgetAll that includes the picture observable now sets picture to @ instead of forgetting it. This allows all of the observables previously referenced by picture to be forgotten and leaves the environment in a sensible state.
(2) However, for other canvases the behaviour is different. Attempting to forget an observable that is linked to a secondary canvas created with createCanvas, or one that is linked with a HTML view created with createHTMLView, will cause both the observable and the system-defined updating mechanism to be forgotten. For example:
createCanvas("picture2");
picture2 is [Circle(300, 150, 100)];
forgetAll("");
Subsequently executing the following statement does not cause the view to update because forgetAll caused the relationship between the observable and the canvas to cease. Use createCanvas again to reinstate the relationship.
picture2 is [Circle(300, 150, 100)];
However, picture2 will have @ assigned to it immediately prior to picture2 being forgotten, which will erase the previous canvas contents rather than leaving them visible and making the view look "hung".
The view cannot be closed automatically because in general the system doesn't keep any record of which observables are mapped to which views. The updating is all done with triggered procedures (or JS Observers, the JavaScript equivalent of triggered procedures). In any case, one objective of forgetAll is that it should preserve the window layout (as requested by Peter).
Does this new behaviour seem reasonable? There is bit of inconsistency here, in that picture is treated differently to picture2. Things would be neater if we could apply the same behaviour to both. However, if we don't do what I've suggested for picture2 then in what sense are we forgetting everything if the user-defined observable picture2 still exists? However, if we applied the behaviour suggested for picture2 to picture as well and picture were truly forgotten (as in deleted, not just set to @) then how would a novice know that they have to use createCanvas to create a relationship between an observable and a canvas?
*However, there is currently a bug whereby trying to assign the result of forgetAll("") to an observable won't work because you are simultaneously forgetting the observable that you're trying to assign to and the forgetting and the assignment are happening in the wrong order. The cause of the bug is deeply embedded into the way the interpreter works and cannot be easily fixed.
from js-eden.
Still not working for secondary canvases.
from js-eden.
forgetAll("") preserves "system symbols". However, the definition currently used of a "system symbol" is one that is both defined by the system and is unlikely to be modified by the user. This is the correct definition in many cases, e.g. for determining which definitions need to be output by the script generator. However, there is also a second category of observables that are initialized to non-zero values by the system but are subject to change by the user, e.g. radiansPerUnit. forgetAll("") forgets these observables. It doesn't reset them to their default values. Thus it is unclear to what extent forgetAll("") can be used as a rapid way of resetting the symbol table, since a full and accurate reset procedure would clearly be more complicated that simply forgetting symbols alone.
from js-eden.
Related Issues (20)
- Scope expressions
- how to upload firmware to the device using the Arduino IDE
- Embed canvas in markdown
- AST operators
- Nameable and first class whens
- Refactor: move core to npm packages
- Performance on SQL queries
- LocalStorage Clearing
- Alternative proc syntax
- Opening tab for library function should be smaller
- Large tabs cause performance problems
- Construal comments no longer working
- XOR operator taking wrong type branch
- Scope limits need a warning
- Provide a smoother cs2 to cs3 conversion process
- Admin construal editing
- ScriptView selector issue if construal title starts with a number
- Fix GUI/proc on p2p
- Custom operators
- Namespaces for extension construals
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-eden.