-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Remove EQUS
expansion?
#905
Comments
I'm not fundamentally opposed to this, but current use cases for All in all, it's a pretty reasonable proposal, particularly considering that there's the braced identifier fallback for complex metaprogramming cases. But at the same time, alternatives need to be in place before this becomes a possibility. |
Another argument for obsoleting As for inline macros, they would be a new feature, so we could design a terser, less line-reliant syntax for their definitions. Making them token-based (which is also motivated by other factors) would greatly help with this. |
I agree; fortunately 0.6.0 with user-defined functions is a pretty long way away, so there's plenty of time to gather more examples of how projects use
My first thought is "do we really need a fourth way to do content replacement", but I'll wait and see. |
EQUS
expansion has a few problems.{interpolation}
and macro arguments, it occurs afterpeek
ing and reading a complete identifier. This means that the lexer reacts to the identifier's presence before it gets expanded. For example, ifEMPTY EQUS ""
, thenld a, \ EMPTY
gives an error "Begun line continuation, but encountered character 'E'" whereasld a, \ {EMPTY}
does not.{interpolation}
and macro arguments, the expanded contents can be anything, even multiple lines, but nothing makes the bare identifier stand out as being so potentially disruptive. For example, inld a, 2 plus 2
, ifplus EQUS ";"
then it gets treated as a comment. It can also interact weirdly with statements that parse their own newlines (REPT
,FOR
,MACRO
, etc).If
EQUS
expansion were eliminated, then string identifiers could work just like numeric ones: evaluate to their literal contents. This would let people writeSTRING
instead of"{STRING}"
, which I think is a big improvement, especially in longer expressions likeSTRIN(HAYSTACK, NEEDLE)
.On the other hand, this would be a very backwards-incompatible change: people rely on
EQUS
expansion for certain use cases that other features don't yet cover. We would need to at least have acceptable substitutes. The use cases I'm familiar with:CUR_THING EQUS "X"
and thenCUR_THING EQU 42
will act likeX EQU 42
. This can already be done with interpolation like{CUR_THING} EQU 42
, and that's required for the newDEF {CUR_THING} EQU 42
syntax. (Expansion inCUR_THING EQU 42
was confusing anyway.)tiles EQUS "* 16"
lets you dold a, 7 tiles
, orN EQU ($30 + 6) tiles - 1
. Macros have to be a complete line so you need different macros for each situation, and interpolation makes the user-defined pieces stand out too much (ld a, 7 {tiles}
isn't as plainly readable). This will eventually be doable with user-defined functions (see [Feature request] User-defined functions #201), likeld a, tiles(7)
, although such functions will ideally support variable arguments to match everythingEQUS
can do.DEF pusha EQUS "push af\npush bc\npush de\npush hl\n"
. For short cases liketext EQUS db 0,
, it's simpler to write and to read than a three-lineMACRO text / db 0, \# / ENDM
. This could be done with a combination of single-lineDEF mac MACRO ...
syntax (see [Feature request] Single-line macro syntax #902) and allowing multiple instructions on one line with a statement separator (see [Feature request] Allow multiple instructions on one line with separators #805). However the discussion for those feature requests brought up some valid objections, and unlike user-defined functions, they aren't really useful except as a substitute forEQUS
.If anyone's relying on
EQUS
expansion for something more idiosyncratic or complicated, then at least interpolation can fill all its use cases. On the one hand,{STRING}
is less user-friendly thanSTRING
; on the other hand,STRING
is more user-friendly than"{STRING}"
, and I think the latter is a lot more common than the former (after making use of user-defined functions and macros when possible).The text was updated successfully, but these errors were encountered: