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

trace variables #4037

Closed
aplicacionamedida opened this issue Jul 15, 2015 · 4 comments
Closed

trace variables #4037

aplicacionamedida opened this issue Jul 15, 2015 · 4 comments

Comments

@aplicacionamedida
Copy link

Trace variables: A function is called each time a variable is accessed or geted.

@vendethiel
Copy link
Collaborator

How do you implement that efficiently anyway?

@aplicacionamedida
Copy link
Author

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.

@notslang
Copy link

notslang commented Nov 4, 2015

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.

@GeoffreyBooth
Copy link
Collaborator

Closing as this proposal doesn’t appear to have consensus.

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

4 participants