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

user accessible lineinfo #118

Open
lutzhamel opened this issue Jan 29, 2022 · 2 comments
Open

user accessible lineinfo #118

lutzhamel opened this issue Jan 29, 2022 · 2 comments
Labels
enhancement Features that are directly related to the core tenet of Asteroid

Comments

@lutzhamel
Copy link
Collaborator

Under certain debugging circumstances it is useful to know exactly where a program is in a file. For this we propose a builtin variable: __lineinfo__. A user can read this variable to obtain a (module name, lineno) pair,

let (mod,ln) = __lineinfo__.

The variable mod will be instantiated with the module name as an Asteroid string and the variable will be associated with an integer value representing the current line number.

Does it make sense to have a function that does the opposite; setting the module name and the line number? E.g.,

__set_lineinfo__ (new_mod_name, n).
@lutzhamel lutzhamel added the enhancement Features that are directly related to the core tenet of Asteroid label Jan 29, 2022
@olwmc
Copy link
Collaborator

olwmc commented Feb 8, 2022

Does it make sense to have a function that does the opposite; setting the module name and the line number?

This is tricky! Lineinfo to me seems more like an observation of state than a mutable object, if that makes sense. So initially I don't think it would make sense to have it but at the same time it might be nice to have in some situations? Maybe for a future testing framework or for more meta asteroid-within-asteroid stuff? Not sure!

@lutzhamel
Copy link
Collaborator Author

The reason why I ask that question is because the C compiler supports line directives. The C compiler could be compiling one file and you can make it think it compiles another. The reason being that it needs to support the C preprocessor...

I don't know if it makes sense to have this in Asteroid...but then, why not...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Features that are directly related to the core tenet of Asteroid
Projects
None yet
Development

No branches or pull requests

2 participants