Here's my spin on the whole macro issue, not that what you need is yet another perspective. This is a message I sent to Mr. Turner but figured it would be best if I posted it to the list as well. ------------- Hello, I have been playing close attention to your discussion with George on the CircleMUD list. When I first started my mud, I knew very little of C (I could make Hello world programs, that was about it). I found the MACROS to be very convenient when learning the structure of the code, and consequently, when I began to add in new features on my own, I added a lot of macros everywhere throughout my code. I was, and until recently, have been a huge fan of macros. But your suggestions on the list made me start to think. I know from experience when I have done stuff like: sprintf(buf, "Your title is %s.", GET_TITLE(ch) ? GET_TITLE(ch) : "Not yet set"); That it got kind of tedious. Granted this is a silly example but it gets the point across. Your ideas made me think, doing GET_TITLE(ch) as a function would be better: const char *GET_TITLE(ch_data * ch) { if (!ch->player.title) return ("Not yet set."); else return (ch->player.title); } More typing at first but saves you a lot of time later. Then I realized I was having problems with CAN_SEE (a fact you mentioned) and so I rewrote the entire thing as a set of functions, which makes the code both easier to understand and read, but also makes the logic much easier to folow and safegaurd against. In short, I wanted to thank you for bringing the subject up, it made me realize that, while a great learning tool, Macros can indeed be a limitation in the end (and slow you down as well, witness all the extra typing in the title example). Rasdan (James Thomas) / \ _ ) (( )) ( (@) /|\ ))_(( /|\ _ |-|`\ / | \ (/\|/\) / | \ (@) | | ------------/--|-voV---\`|'/--Vov-|--\--------------|-| |-| '^` (o o) '^` | | | | James C. Thomas Jr. `\Y/' Founder of Finality |-| |-| rasdan@finality.drachen.com | | | | finality.drachen.com 4000 |-| |_|_____________________________________________________| | (@) l /\ / ( ( \ /\ l `\|-| l / V \ \ V \ l (@) l/ _) )_ \I `\ /' ` +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST