Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] Re: (PR#13005) latest CVS (assertion failed, effects.c)
Home

[Freeciv-Dev] Re: (PR#13005) latest CVS (assertion failed, effects.c)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bdunstan149@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#13005) latest CVS (assertion failed, effects.c)
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Sun, 8 May 2005 09:13:19 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13005 >

On Sun, 8 May 2005, Jason Short wrote:

> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13005 >
>
> Vasco Alexandre da Silva Costa wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13005 >
> >
> > I suppose we could be using a different API though. The way this has
> > evolved, I think a single varargs function would be better. e.g.:
> >
> > int get_effect_bonus(enum effect_type effect_type, const char *fmt, ...)
> >
> > get_effect_bonus(EFT_HAVE_EMBASSIES, "p", pplayer)
> >     -> get_player_bonus
> >
> > get_effect_bonus(EFT_MAKE_HAPPY, "c", pcity)
> >     -> get_city_bonus
> >
> > get_effect_bonus(EFT_OUTPUT_ADD_TILE, "cto", pcity, ptile, poutput)
> >     -> get_city_tile_output_bonus
> >
> > etc.
>
> Please no.  You give away all typesafety and any hope at catching errors
> at compile time.

Are a zillion different functions better?

Other than variable arguments, I see no reasonable solution. If that is
the price, I say typesafety be damned.

You could do run-time checks of argument types if all the entities in the
game had a type field at the same offset. But that is probably a waste of
time.

Just be vewwy cawefwl when using it...

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa





[Prev in Thread] Current Thread [Next in Thread]