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

Lazy definitions #13

Closed
3 tasks done
rksm opened this issue Jun 4, 2016 · 3 comments
Closed
3 tasks done

Lazy definitions #13

rksm opened this issue Jun 4, 2016 · 3 comments

Comments

@rksm
Copy link
Member

rksm commented Jun 4, 2016

Entities in the top-level such as class and object definitions currently get re-defined on moduleSourceChange and reloadModule operations. Often modifications of those objects that keep the original identity reflect the users intentions better.

  • identify objects whose identity should be maintained
  • for those objects, implement an update strategy*
  • use those updates via options, e.g. options.resetEnv = false in reloadModule could signal to keep objects, maybe a more explicit behavior is better

*The tricky part are deleted sub-elements such as methods and properties for classes. Given that an object or class can be extended in multiple places, we cannot simply remove all props/methods that don't occur in the latest class / obj definition. What's needed is to track the location of these sub-elements and compare them with the location of the re-definition to figure out if a prop/method should be removed.

@rksm
Copy link
Member Author

rksm commented Jun 10, 2016

When capturing code with options.keepPreviouslyDeclaredValues = true we will lazy initialize objects and classes, maintaining their identity when they already exists. The policy for that is currently implemented in lively.ast.evalSupport.declarationWrapperForKeepingValues.

Note: We currently DO NOT remove elements that don't appear in the definitions anymore. So when you first evaluate class Foo { m() {} } and then class Foo {}, Foo will still have a method m! Since this should work for most cases I will leave this as an open item with low priority for now.

@rksm
Copy link
Member Author

rksm commented Aug 21, 2016

Keeping identity for arbitrary objects turned out to be confusing. We keep classes around via initializeClass. The declaration wrapper still exists and might be useful for other hooks but if we don't find any it will be removed in the next version.

@rksm rksm closed this as completed Aug 21, 2016
@levjj
Copy link

levjj commented Aug 22, 2016

I would also be in favor of actually removing methods and accessors from classes when the class definition changes. It may seem like an edge case but there have been multiple confusing situations caused by out-dated methods and accessors being called after renaming them in the class definitions. This could also cause problems with a method got deleted with the intention of calling the superclass. In that case, leaving the out-dated method prevents the super call.

This could be problematic if classes could be extended but as long as there are no mixins, it should be fine.

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

No branches or pull requests

2 participants