Re: Least favorite quirk

From: Mike Breuer (
Date: 07/31/01

From: "George Greer" <greerga@CIRCLEMUD.ORG>
>   SPECIAL(shopkeeper, ch, me, cmd, argument)
> so that the arguments can be named whatever you want, but then you forget
> the types.  What might be better is:
>   SPECIAL(void shopkeeper(struct char_data *ch, void *me, int cmd,
>         char *argument)
> where SPECIAL is:
>   #define SPECIAL(x)    x
> That removes the benefit of easily changing the variables for your special
> procedures though.  All of them must have the same arguments anyway.

I played around with it some, and the solution that I like is similar to your
first one:

#define SPECIAL(name) \
   int (name)(struct char_data *, void *, int, char *)

#define SPECIAL_IMPL(name, ch, me, cmd, argument) \
   int (name)(struct char_data *(ch), void *(me), int (cmd), char *(argument))

This way SPECIAL(shopkeeper) can be used for prototype declaration, and
SPECIAL_IMPL can be used for implementation: SPECIAL_IMPL(shopkeeper, ch, me,
cmd, argument)

SPECIAL(*func) is still available with this method.  Removing the parameter
names from SPECIAL prevents people from reverting to the old method out of
laziness (although they can always add the names back in).

I think this is at least an improvement because one can see (and change) the
parameter names in the implementation.  return value and parameter types
should be documented in comments somewhere in spec_procs.c for convenience.
Similar measures can be taken for the other macros.


   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/06/01 PST