-
-
Notifications
You must be signed in to change notification settings - Fork 180
Open
Labels
enhancementTypically new features; lesser priority than bugsTypically new features; lesser priority than bugsrgbasmThis affects RGBASMThis affects RGBASM
Milestone
Description
Spinoff from the comments of #201. I've encountered a use case for this twice recently:
- In pokered, we twice want to do
assert COND, "message"but then useCONDin some further logic. Having to define a temp variable would be more trouble than it's worth vs just repeating theCONDexpression. - In pokecrystal, we repeat this pattern for getting an unlabeled SRAM location from its labeled WRAM counterpart:
What I'd rather do:
ld hl, sPlayerData + (wEventFlags - wPlayerData) ld hl, sPlayerData + (wHallOfFameCount - wPlayerData) ld hl, sPlayerData + (wPlayerID - wPlayerData) ; etc
However, that would be unsafe to use without a precondition ofdef Saved(label) = sPlayerData + (label - wPlayerData) ; user-defined function ld hl, Saved(wEventFlags) ld hl, Saved(wHallOfFameCount) ld hl, Saved(wPlayerID) ; etc
label >= wPlayerData && label < wPlayerDataEnd. User-defined functions are single expressions, so we would need an expressionassert:def Saved(label) = \ ; user-defined function assert(label >= wPlayerData && label < wPlayerDataEnd, "Cannot save label") * \ sPlayerData + (label - wPlayerData) ld hl, Saved(wEventFlags) ld hl, Saved(wHallOfFameCount) ld hl, Saved(wPlayerID) ; etc
We could probably also handle three-arg assert(warn/fail/fatal, cond, msg).
Metadata
Metadata
Assignees
Labels
enhancementTypically new features; lesser priority than bugsTypically new features; lesser priority than bugsrgbasmThis affects RGBASMThis affects RGBASM