Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] Re: (PR#8239) Speclist generator
Home

[Freeciv-Dev] Re: (PR#8239) Speclist generator

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8239) Speclist generator
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 23 Mar 2004 02:20:21 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8239 >

On Tue, 23 Mar 2004, Raimar Falke wrote:
> I don't see that the specfiles are hard to use. With <10 lines you get
> a type safe list. That is good.

Until you use several (5+) of them in a single file. Then both your .h and
.c file gets filled up with hard to read, quick to err macros.

I think it is important for code readability that .h files are easy to
read.

On Mon, Mar 22, 2004 at 11:32:10AM -0800, Jason Short wrote:
> > Maybe eventually all of Freeciv will be coded via python generators?
...
> > Maybe this code would be better off coded directly in python and linked
> > to C? (I'm not sure if this is possible because a lot of it is
> > macros.)

The transaction cost alone would not make it worth it, I would guess.
Besides, an embedded high-level language should be used for resolving
high-level issues, like rules, not for replacing low-level code.

> Generators should be used if there is code which has a high
> abstraction which the C-compiler doesn't understand. I think that
> speclist problem doesn't have this abstraction value.

The C-compiler doesn't understand that a function, such as genlist_get(),
should return or take a type depending on the list type. So the authors of
the current speclists made a clever hack using cpp that generates separate
.c code for each list (our first code generator). However, this clever
hack does not work with macro or inline functions. So in a way we do have
an abstraction problem that the C compiler doesn't understand.

> So I don't see much places were we can increase the abstraction by
> using generators like we did with the packets generator.

Oh, just wait. Once you've found yourself a hammer, you'll be seeing nails
everywhere :-)

While on that particular topic, I plan on generalizing the idex system as
well (the combined hashtable/genlist system used for cities and units), so
that making new idex lists should be a snap. This could also be rolled
into a generator.

  - Per




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