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

NOLOL string building #86

Closed
AstraLuma opened this issue Aug 15, 2021 · 5 comments
Closed

NOLOL string building #86

AstraLuma opened this issue Aug 15, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@AstraLuma
Copy link

It is currently annoyingly difficult to build up a complex string with variable substitutions (eg, building up the value for a text panel).

Doubly so if you want to do so in an optimized manner (minimizing lines).

My current example, as psuedo-nolol:

:zd_status = f""":p1_score :p2_score :p3_score :p4_score :p5_score :p6_score
Current Player: :current_player
Brains: :brains
Shotguns: :shotguns
"""

Naive writings compile down to 5 or 6 lines, but I'm pretty sure the compiler (or a less lazy me) could do better.

@AstraLuma AstraLuma added the enhancement New feature or request label Aug 15, 2021
@AstraLuma
Copy link
Author

A naive version:

:zd_status = :p1_score + " "
:zd_status += :p2_score + " " 
:zd_status += :p3_score + " "
:zd_status += :p4_score + " " 
:zd_status += :p5_score + " " 
:zd_status += :p6_score
:zd_status += "\nCurrent player: " + :current_player 
:zd_status += "\nBrains: " + :brains 
:zd_status += "\nShotguns: " + :shotguns

This compiles to 6 lines. Reducing it to :zd brings it to 5 lines.

@dbaumgarten
Copy link
Owner

I understand what you are trying to archive with this feature.
But I see a few difficulties here.

  1. The multi-line style you are suggesting usually causes issues with indentation
  2. Compiling it to something efficient isn't that easy. The most efficient thing would be one big assignment. But that might not fit into the line and would need to be divided into multiple parts. But this division might cause unexpected timing-issues, as something that appears to be a single statement is stretched accross multiple lines.

I think a lot of Issues would arise trying to implement this feature, and I am not convinced that it's worth it. Most people seem to be doing fine with just adding up strings.

P.S. while I am always happy about people opening new issues, I would also be quite happy about getting responses on questions regarding already existing issues ;)

@AstraLuma
Copy link
Author

I mean, yeah, it probably won't be a single-line action. But it would be nice if I didn't have to do all the minimization manually.

@dbaumgarten
Copy link
Owner

#78 will help with string-building by automatically moving constants to a satup-line.
Also, I was thinking about a feature that allows the splitting of very long expressions accross multiple lines, but the details here are still a bit unclear.

All in all I would prefer it, if the optimization of string-building is handled by some kind of general optimizations instead of a specific string-building feature.

@dbaumgarten
Copy link
Owner

Closed as won't fix.
Hopefully the upcoming optimizations reduce the need for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants