asteroid icon indicating copy to clipboard operation
asteroid copied to clipboard

user accessible lineinfo

Open lutzhamel opened this issue 4 years ago • 2 comments

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 avatar Jan 29 '22 00:01 lutzhamel

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!

olwmc avatar Feb 08 '22 19:02 olwmc

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...

lutzhamel avatar Feb 08 '22 22:02 lutzhamel