asar
asar copied to clipboard
Request for additional string escapes
I am writing some code that works with a lot of strings and the absence of some common string escapes has become inconvenient.
Most notably missing:
- macro arguments:
\<($3c) (there is already\!so this one just seems like an omission) - newline:
\n($0a) - tab:
\t($09)
I know you can write db "stuff",$0a,"more stuff" but ",$0a," is a lot of typing compared to \n and I assume it would not be very much effort to add these to Asar.
First and foremost, allow me to suggest a temporary work around:
!n = """,$0a,"""
db "123!n"
Now, as for the actual request: I'll look into it, but changing core string parsing in asar is extremely dangerous. The feature may be trivial, but the side effects perhaps more subtle and obnoxious than one may expect. So a quite non-trivial amount of testing will be required. If you happen to get bored and want to write some unit tests I'd appreciate it, but otherwise I'll take a look some time later today or Saturday.
I had thought of something like !n but hadn't realized there was a way to get " into a define (I knew defines could be quote-delimited but didn't realize that meant you could put escapes in them). That honestly basically solves the problem for my use case. I can also see how a new way to put a newline into a define might cause problems, and given that I mainly wanted this as a convenience thing it seems reasonable not to put a bunch of effort into it. So, uh, sorry for making an unnecessary request!
I still feel like \< should probably exist, but even as someone not very familiar with the parser I can easily see how that one might be haunted, and I think something like "<","a>" avoids macro substitution just fine in most of the relevant contexts.
I wouldn't call this request unnecessary at all. Asar is just a little special and needs extra care. There is a reason main.cpp opens with
// "because satanism is best defeated by summoning a bigger satan"
// ~Alcaro, 2019 (discussing Asar)
#include "addr2line.h"
I'll still probably look into fixing this as there are use cases. Especially since my homebrew has a lot of story elements planned, I may need this sort of thing myself. I should also note: this define trick does have some use as a pseudo-digraph (more like ngraph, but you get what I mean). So if you have "special characters" in dialogs you can use this method to inline them more directly. Arguable whether this is good or not. But its an option at least.
EDIT: Alcaro has decided I should clarify asar is not "just a little special" and more like immeasurably special.