Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [RFC PATCH] init_techs
Home

[Freeciv-Dev] Re: [RFC PATCH] init_techs

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [RFC PATCH] init_techs
From: Arien Malec <arien_malec@xxxxxxxxx>
Date: Sun, 23 Sep 2001 21:34:56 -0700 (PDT)

--- Justin Moore <justin@xxxxxxxxxxx> wrote:
> > If the parsing code typechecks, the callback functions can be:
> >
> > typedef void (*int_command_func) (int);
> > typedef void (*str_command_func) (char *);
> > typedef void (*int_list_command_func) (int, int *);
> > typedef void (*str_list_command_func) (int, char **);
> >
> > (For the list callbacks, the first function is the size of the list).
> 
>    Why?  Just pass everything that wasn't the command to the function.
> The overall framework doesn't need to know what each function takes.  Fx:
> 
> /set xsize 80
>  ^^^ ^^^^^^^^

Every callback function that takes int must then do atoi and return an error
message. The chances that the error message will be standardized is almost nil,
and it is more programmer efficient to do the atoi once, and let the
programmers of callbacks assume that they are getting things in the right
format.

> /set attribute nation.Greek.techs Alphabet,Iron Working
>  ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I hope that the syntax ends up being "set dotted.thing value", otherwise we
have yet another set of callbacks to be maintained by the attribute callback.

Again, if every callback has to parse its own string lists, some commands will
accept "Alphabet,Iron Working" but not "Alphabet, Iron Working", some will want
the list to be enclosed in quotes, some not, some will parse down to
(Alphabet,Iron,Working) etc. The syntax for providing a list of strings and/or
ints is an integral part of the ruleset/command language, and shouldn't be left
to be invented by scores of different callback functions written by scores of
different programmers.

If we decide to go the untyped approach then we should at least provide four
parsing functions that return int, char *, int *, and char ** and standardize
syntax & error handling. I still think this is something that the framework
should provide.

> These callbacks should be
> content-oblivious, and it should be up to the specific functions to
> interpret the data correctly.

That way lies madness....

Arien 

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. 
http://im.yahoo.com


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