-
Notifications
You must be signed in to change notification settings - Fork 16
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
Macro: dynamic variable naming #105
Comments
I understand why something like this would be helpfull. I have been thinking about adding a template-engine to the mix, kind of like the C preprocessor, that could be used for code-generation. But I fear that that might be complete overkill. |
I'm just throwing out ideas and seeing what sticks. Maybe a template-engine based on a subset of the lua syntax, limited to string manipulation or only string output? Let the end user build their own micro template-engine. Or maybe include go code or something, that what ever functions from that include could be called and the resulting string output would be passed on as nolol to yodk. |
Go has it's own built-in templating language: https://pkg.go.dev/text/template But thats adding a whole new (quite complicated) language to the mix. And I am also unsure about the interaction between the templating and yolol. It could make things quite chaotic, especially be throwing of the line-numbering in error-messages. |
After sleeping on this for a while. What about some kind of string builder that takes a variable, number, and delimiter |
The issue i see with that is: What happens once the generated expression reaches the char-limit? Such a "builder"-feature would need to generate seperate statements, which can then be merged into as few lines as possible by the compiler (possibly in combination with #52 ) |
Maybe someone will find this useful or not. Here is what I'm using as a stop gap. It's looking for something formatted like this
It looks for lines starting with |
I am glad you found a workaround for yourself. I still would like to add something like this natively to nolol, but I still haven't found a way of doing to, without introducing a gigantic amount of complexity... |
Is your feature request related to a problem? Please describe.
I'm trying to write useful macros that allow only calling one macro. There currently isn't a way to dynamically create variables, but I think macros would be perfect for the job.
Writing hundreds of similar macros is a bit tedious. Take for example these two macros and expand that to 100 similar functioning macros, but with additional parameters.
Describe the solution you'd like
Something to akin to the following would make the whole thing much easier to maintain and others easier to utilize.
Resulting yolol code:
For when the line length is to long:
Describe alternatives you've considered
I don't know how the syntax should be, but I hope that the above gives some inkling of what I'm trying to communicate.
The text was updated successfully, but these errors were encountered: