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: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8239) Speclist generator
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Tue, 23 Mar 2004 03:08:25 -0800
Reply-to: rt@xxxxxxxxxxx

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

On Tue, Mar 23, 2004 at 02:20:21AM -0800, Per I. Mathisen wrote:
> 
> <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.

You know that with your approach the localization of the types and
functions go away. Currently you can assume that if there is no
foolist.h file that this list type is declared in foo.h.

Can you cite a file which has 5+ list declaration in a single file?

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

That we should ban macros and inline functions from the header files.

> 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.

I agree.

> > 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.

Yes.

> 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).

Yes the cpp is used as a generator. It is the good natural choice
since it is portable, available and requires no extra time. You
yourself wanted to implement the packet generator with cpp.

> However, this clever hack does not work with macro or inline
> functions.

Can you explain this in more detail?

> So in a way we do have an abstraction problem that the C compiler
> doesn't understand.

The C compiler doesn't understand it in the form we model it.

> > 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 :-)

I just want to calm Jason. So that he doesn't think we can a big
number of python code or generators in the next months.

> 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.

Hmmm. idex is only a wrapper around hashtable. There is no genlist
involved.

> This could also be rolled into a generator.

Or the cpp is used like for speclists now.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  Microsoft does have a year 2000 problem. I'm part of it. I'm running Linux.




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