asar icon indicating copy to clipboard operation
asar copied to clipboard

Singe quoted strings?

Open trillllian opened this issue 7 years ago • 5 comments
trafficstars

ExE Boss on discord:

Also with asar, another option would be to add ' delimited strings which would be processed as is (only applying the table mapping if it’s being used).

This could quite easily be done, since most places that use quoted strings use a single dequote() function, and define expansion also happens in one place.

trillllian avatar Mar 14 '18 18:03 trillllian

As far as I know, ' is already used as a delimiter for characters in Asar (not documented in the manual yet; was planning to add that to the manual later).

db 'x'

if I remember correctly, this would write whatever is currently mapped to the character x to the ROM.

If we wanted to add this, I suppose we would need another delimiter.

Not sure how useful this feature actually is, though, since as far as I know, calling cleartable once at the start of the file does essentially just that. It resets your table to useing a direct ASCII mapping, which of course only changes to another mapping once you call table. pushtable/pulltable are also useful in scenarios where tables are expected to change.

Does ExE Boss have any concrete usage example where this future would help with a specific problem?

RPGHacker avatar Mar 14 '18 20:03 RPGHacker

It was a reply to a problem of not being able to have ! in strings. This would just mean that it wouldn't evaluate defines and could be used for making sure incbin/incsrc don't have problems when there's a ! in the path. So you could do

incsrc '../../!IMPORTANT STUFF/test.asm'

and Asar wouldn't try to evaluate !IMPORTANT.

trillllian avatar Mar 15 '18 05:03 trillllian

Oh, I see wht you mean. Kinda like in Ruby. If I remember correctly, you added an escape character for ! recently, though, right? Does that work in those cases?

RPGHacker avatar Mar 15 '18 09:03 RPGHacker

Quick question: Is it useful to have

incsrc "../../!IMPORTANT STUFF/test.asm"

be macro expanded? Does any real code use this or something similar for other uses of strings? Because if it is not used, then we could just treat this as a bug: defines should not be expanded in strings.

I am a bit concerned here: The more we add things like escaping exclamation marks to the language, the more difficult it will be to parse, which makes it difficult to make changes to the code because everything is even more entangled than it is already. I see this directly today, since I try to write a new assembler which has a somewhat decent compatibility with Asar's language. But having two different kinds of string types, one which escapes and one that does not, together with am method to escape the character which designates defines, etc., etc. further and further restricts me in using a more sensible approach to parsing like having a decoupled lexing and parsing stage since the grammar of Asar becomes more and more difficult to parse. I would rather hope to see that we stop adding "quick hacks" on top of existing hacks and take our time if those changes are actually needed and what the consequences of this change are. Is it only a small change, which is consistent with the current language design, like adding a new command like pushbase or does it change something more fundamental? And I would hope that we have the bravery to deprecate/remove some of the superfluous features and try to come up with something simple to replace them.

Horrowind avatar Mar 15 '18 09:03 Horrowind

I think define expansion inside strings is used occasionally, yeah. Mostly for prints. I think some of my own code even uses it. As far as I know, Asar's main problem is that it just expands defines wherever and doesn't really care about checking where it is. I'd be afraid that changing this would actually affect quite a lot of code out there, though. I think a lot of people saw it more as a future than as a bug (which might have also been intended by Alcaro, I don't know).

And I agree with you that Asar's syntax is difficult to parse, but I'd say it's mostly because of ambiguities, syntactical sugar, a lack of a pre-processor and a lack of clarity/consistency (most of it inherited from xkas, some of it newly added). For example: how the language randomly accepts math in one place, but not in another place (incbin) or how a "" means something different in define assignments than it means in functions or in print statements. That being said, I don't think new additions to the language hurt as long as they aren't ambiguous (that's why I would avoid using ' as a delimiter for those strings, since that's already used in other places) and as long as they're legitimately useful (whether this proposed change actually is I can't say, though I do think that at least having an escape character is useful enough, and all programming languages have some, I don't necessarily consider it a hack in this case).

At the same time, I feel like when writing a new assembler from scratch and already being okay with getting rid of some backwards-compatibility on commonly used features, there's no point in having the new assembler be inspired by Asar in the first place. In that case, I'd just go with a new and cleaner syntax alltogether (maybe write a tool which attempts to auto-convert Asar code to code for this new assembler). I mean, there probably already are way cleaner and more well-defined SNES assemblers out there than Asar, so when breaking compatibility with Asar, anyways, I feel that it would be smarter to work off of those.

RPGHacker avatar Mar 15 '18 10:03 RPGHacker