I propose a new feature for future versions of Julia that comments support mathematical typesetting similar to LaTeX/TeX, and also a way to write variables by their name in comments something like:
my_var = 5
# value of my variable is $(my_var)
This can be new type of commenting which gets replaced by other text after the code gets executed once. This can be a hit on performance but for sake of its purpose of better presentation it may not matter that much. It may be helpful for academic and teaching purposes.
a way to write variables by their name in comments
What does that mean? A comment is not executed, you just read it in the source code file.
It can be like a one time execution on the first run of program that gets replaced.
So after the above program is run, it would have to write to the currently open file and update the location of my_var with the value?
It seems like maybe Notebooks for Academic/Teaching folks would serve the same purpose as this.
So after the above program is run, it would have to write to the currently open file and update the location of
my_varwith the value?It seems like maybe Notebooks for Academic/Teaching folks would serve the same purpose as this.
But an .ipynb file can not be used as a .jl script for many purposes.
I think a tool like Weave.jl is the right approach to this.
But an .ipynb file can not be used as a .jl script for many purposes.
https://github.com/fredrikekre/Literate.jl might be useful
Well it seems like if someone needs this some packages are available and more can be developed for this specific purpose. I just raised the issue following a StackOverflow question about such feature to see how this can be done.
@JaydevSR thanks for opening the issue and suggesting the idea! I hope that Literate or Weave can help cover your use-case!
Most helpful comment
I think a tool like Weave.jl is the right approach to this.