While working on DM, I am discovering that it is really annoying not
to be able to do things like this:
#define LEADER_AND_FOLLOWER X Y
[unit]
id=Leader
..
x,y={X},{Y}
[/unit}
[unit]
id=Follower1
..
x,y={X},{Y}+1
[/unit}
[unit]
id=Follower2
..
x,y={X}+1,{Y}-1
[/unit}
#enddef
The fact that this does not work forces me to write macros in which
(a) there are a lot of hardwired constants with magic relationships
to each other, and (b) these constants are related in unobvious ways
to constants in other files. For an example, see {DELFADOR_REAPPEARS}
in Delfadors_Memoirs/utils/sides.cfg and its calling context in
Delfadors_Memoirs/scenarios/14_Shadowa.cfg.
I would like to fix this. Fixing it will require that I upgrade the
WML interpreter to do expression evaluation in certain places where it
now looks for constants. This is because, after macro expansion, the
expression {LEADER_AND_FOLLOWER 23 17} will expand to code that looks
like this:
[unit]
id=Follower2
..
x,y=23+1,17-1
[/unit}
This would not, on the whole, be very difficult. We already have a
tokenizer, and recursive-descent expression parsers are not difficult
to write.
There is, however, one large blocker in the way - we already have a
meaning for the syntax 17-1; it looks like a range, albeit a bizarre
one. Therefore, as a first step, the range syntax needs to be
replaced with something like '..' (the usual choice in programming
languages written in ASCII) so that '23..25' is unambiguously different
from '23-25'.
This is not a difficult change either, but it's a very intrusive one
that will touch a lot of places in mainline. A grep reveals about 380
places the present range syntax is used, and it will require a wmllint
rule to up-convert UMC.
As a compatibility hack pre-1.8, the expression evaluator could be
taught to return a range when the result of subtracting two numeric
literals would be negative. However, it would be a very bad idea to
leave a crocky rule like this in the language indefinitely. Someone
would surely write an macro that would trigger that rule in an
unexpected way and produce strange, hard-to-diagnoose bugs.
I am requesting comment before I implement this syntax change.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
When only cops have guns, it's called a "police state".
-- Claire Wolfe, "101 Things To Do Until The Revolution"
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev