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: Reinier Post <rp@xxxxxxxxxx>
Cc: Freeciv developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [RFC PATCH] init_techs
From: Daniel L Speyer <dspeyer@xxxxxxxxxxx>
Date: Mon, 24 Sep 2001 09:33:28 -0400 (EDT)

What about a truly general and extendable parsing?  Admittedly, this would
be difficult to write, but break down the command line according to
syntactical rules and then pass each function manually typed void*s.  A
callback function would look like

enum datatype;
void do_command(int argV, datatype argT[], char *argC[]);

Then if a function wants different arguments, it can throw some sort of
generalized error (not literally throw, that's just the idea).  There
could even be a function int checkarguments(int Vgiven,datatype
Tgiven[],int Vwanted,datatype Twanted[]) which would check everything,
give an appropriate error, and then return whether or not the function
should proceed.

If we designed it to be extensible enough, we could get the benefits of
both unified syntax and extendable functions.

--Daniel Speyer
"May the /src be with you, always"


On Mon, 24 Sep 2001, Reinier Post wrote:

> On Mon, Sep 24, 2001 at 01:11:42AM -0400, Justin Moore wrote:
> 
> >    We have standardized error handling through the cmd_reply function.
> 
> It's better to standardize more.  The quality of error messages is
> poor (you want "argument %d of the %s command must be a %s") and
> consistent wording and formatting has to be maintained by hand.
> 
> > And what if I want to parse a float?  Or a float*?  Or a long, long*,
> > void*, or something else we haven't even thought of yet?  We leave them
> > trying to smash a square peg into a round hole.
> 
> Most arguments are of a standard type: a number, a valid player name,
> a valid directory, an arbitrary alphanumeric identifier, a number.
> 
> >    And I maintain that your way lies scores of programmers that want to
> > strangle someone because there is only The One (or Four) True Way(s) to
> > handle this stuff.  IMHO, Perl is the best way to parse strings; I'm just
> > trying to give programmers a content-oblivious, Perl-like way to parse
> > incoming data.
> 
> Your plans are clearly a big improvement.
>  
> > -jdm
> 
> -- 
> Reinier
> 
> 



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