Python for air traffic control?

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Jul 4 14:47:53 CEST 2001


Mirko Liss <mirko.liss at web.de> wrote in 
news:20010704013238.2DC8A00.NOFFLE at niccolo.ke4.de:

> An example in C:
> 
> typedef plane_t int ;  /* plane no */
> typedef lane_t int  ;  /* lane no */
> typedef go_down_in_pieces_t bool ;  
> go_down_in_pieces_t dispatch( plane_t flightno, \
>                               lane_t neigboring_highway ) ;
> 
> If the arguments get swapped, the compiler gets angry.
> Is this what you wanted to have in C ?
> 

No wonder the compiler gets angry, you can't rename your own types as 
'int'. Also there is no type called 'bool' in C. Perhaps you meant:

typedef int plane_t;
typedef int lane_t;
typedef int bool;
typedef bool go_down_in_pieces_t;

go_down_in_pieces_t dispatch(plane_t flightno, lane_t neighboring_highway);

int main()
{
    plane_t plane = 5;
    lane_t lane = 3;
    dispatch(plane, lane);
    dispatch(lane, plane);
    dispatch(dispatch(lane, plane), dispatch(lane, plane));
    return 0;
}

Now the compiler is completely happy. All calls to dispatch give it two 
integers so there is nothing to complain about. C's 'typedef' only defines 
an alias for a type, it doesn't define a new type, and any programmer that 
thinks it does should be locked in a cupboard with a copy of the standard 
and not let out until they have translated it into readable English.

Please tell me you don't do air traffic control for a living.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list