-
Notifications
You must be signed in to change notification settings - Fork 2k
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
trace variables #4037
Comments
How do you implement that efficiently anyway? |
I think that the only solution is to declare a variable with this special property: to be traced. Perhaps the traced variable can be registered internally by the compiler and associate its corresponding callbacks in case of being geted or setted. The compiler adds after each access to a variable a call to the associated callback. Probably the callbacks requires a reference to that variable to be passed as a parameter. This also means that the traced variable needs to be associated to an object , because local vars can't be passed by reference. For example the traced variable could be a property of an object dedicated to store traced variables. This new feature could also be used to emulate the observer pattern. |
JS already has getters and setters, so you could probably use that to do your variable tracing. Or you can track variables using the Blink DevTools/Node Inspector. Though I think that the idea of making tracing a part of CoffeeScript is pretty far out of scope. It would break the "CoffeeScript is just JS" principle, because tracing is way more than just syntactical sugar for common idioms. |
Closing as this proposal doesn’t appear to have consensus. |
Trace variables: A function is called each time a variable is accessed or geted.
The text was updated successfully, but these errors were encountered: