View Single Post
Old February 6, 2019, 10:45   #42
t4nk
Swordsman
 
Join Date: May 2016
Posts: 330
t4nk is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
That is very much not in the usual design patterns model. For dice, it would be an interpreted mini-language. Same for the various case statements for melee types (CRUSH, HURT, SHATTER, etc.) By and large, separation of code and data is very much a usual design goal.
Well, define "code" and "data". Is stuff like dice "data"? It's an expression, with operands and operators, variables even... If dice is ok, why not conditionals? (as proposed) Why not loops? Then you'll end up with a full blown programming language. And if that's the intention you'd better using some ready made one. Like Lua... or, indeed, C.
Anyway, you can separate code and data in C just fine. Angband's edit files just move parsing from C compiler's parser to the ones in parser.c or z-dice.c. And as far as I can tell, the only advantage is avoiding recompilation. It's indeed some advantage (justifying the existence of parser.c), but not a huge one for an open source game like Angband (so I don't think z-dice.c should exist).

Last edited by t4nk; February 6, 2019 at 10:50.
t4nk is offline   Reply With Quote