[M3devel] Shorthand type declarations?

Chris Highjinks at gmx.com
Wed Feb 3 09:59:12 CET 2010


On Tue, 02 Feb 2010 21:37:33 -0600
"Rodney M. Bates" <rodney_bates at lcwb.coop> wrote:

> 
> 
> 
> Unfortunately, this is the shortest you can get.  I suppose the language designers
> thought that, while a whole lot of variables with the same type were a likely
> case:
> 
>    VAR x, y, z, u, v, w, h, i, j, h, ... : INTEGER;   ,
> 
> that more than just a few type names that are synonyms for the same type would not be common.
> 
> You may think me certifiably masochist, but I go the more longhanded way and write:
> 
>   TYPE Window = unsigned_int;
>   TYPE Pixmap = unsigned_int;
>   TYPE Cursor = unsigned_int;   ,
> 
> sacrificing writeability in favor of readability.  (Yes, I repeat VAR and CONST too,
> almost every time.
> 
> 

The reason I asked is because I'm doing the interface for /usr/include/xcb/xproto.h

There are a lot of of typedefs in there that are defined as the same base type.

I've shortened the Iterator types by using...

TYPE T = UNTRACED ROOT OBJECT END;
TYPE XCB_Iterator = T OBJECT
	Rem   : INTEGER;
        Index : INTEGER
END;

TYPE XCBAtom = unsigned_int;
TYPE Atom_Iterator = XCB_Iterator OBJECT
     Atom_Data : UNTRACED REF XCBAtom;
END;

But even this is gonna kill me. Heh. xproto.h is a HUGE file.

-- 
Chris <Highjinks at gmx.com>



More information about the M3devel mailing list