<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
> so you can use a Cursor where a Window would be required etc<BR>
<BR>
Win32 does opaque unique types something like:<BR>
<BR>
<BR>#define DECLARE_HANDLE(foo) struct tag##foo; typedef struct tag##foo* foo;<BR>
<BR>
DECLARE_HANDLE(HWND)<BR>
DECLARE_HANDLE(HCURSOR) <BR>
DECLARE_HANDLE(HRGN) <BR>
DECLARE_HANDLE(HPEN) <BR>
<BR>
Some of the objects are indeed "bases" of others, but that can't be<BR>
easily captured. It gets documented and you can cast.<BR>
<BR>
And then opaque non-unique is also common:<BR>
typedef void* HANDLE;<BR>
That is used for files, events, mutexes, semaphores, processes, threads, etc.<BR>
And there is a lot of commonality.<BR>
They all work with CloseHandle, WaitForSingleObject, WaitForMultipleObjects,<BR>
DuplicateHandle, etc.<BR>
<BR>
- Jay<BR><BR> <BR>> Date: Wed, 3 Feb 2010 10:18:14 +0100<BR>> From: wagner@elegosoft.com<BR>> To: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] Shorthand type declarations?<BR>> <BR>> Quoting Chris <Highjinks@gmx.com>:<BR>> <BR>> > On Tue, 02 Feb 2010 21:37:33 -0600<BR>> > "Rodney M. Bates" <rodney_bates@lcwb.coop> wrote:<BR>> ><BR>> >> Unfortunately, this is the shortest you can get. I suppose the <BR>> >> language designers<BR>> >> thought that, while a whole lot of variables with the same type <BR>> >> were a likely<BR>> >> case:<BR>> >><BR>> >> VAR x, y, z, u, v, w, h, i, j, h, ... : INTEGER; ,<BR>> >><BR>> >> that more than just a few type names that are synonyms for the same <BR>> >> type would not be common.<BR>> >><BR>> >> You may think me certifiably masochist, but I go the more <BR>> >> longhanded way and write:<BR>> >><BR>> >> TYPE Window = unsigned_int;<BR>> >> TYPE Pixmap = unsigned_int;<BR>> >> TYPE Cursor = unsigned_int; ,<BR>> >><BR>> >> sacrificing writeability in favor of readability. (Yes, I repeat <BR>> >> VAR and CONST too,<BR>> >> almost every time.<BR>> ><BR>> > The reason I asked is because I'm doing the interface for <BR>> > /usr/include/xcb/xproto.h<BR>> ><BR>> > There are a lot of of typedefs in there that are defined as the same <BR>> > base type.<BR>> ><BR>> > I've shortened the Iterator types by using...<BR>> ><BR>> > TYPE T = UNTRACED ROOT OBJECT END;<BR>> > TYPE XCB_Iterator = T OBJECT<BR>> > Rem : INTEGER;<BR>> > Index : INTEGER<BR>> > END;<BR>> ><BR>> > TYPE XCBAtom = unsigned_int;<BR>> > TYPE Atom_Iterator = XCB_Iterator OBJECT<BR>> > Atom_Data : UNTRACED REF XCBAtom;<BR>> > END;<BR>> ><BR>> > But even this is gonna kill me. Heh. xproto.h is a HUGE file.<BR>> <BR>> What exactly is gained by defining all those aliases for unsigned_int?<BR>> In M3 all the types are structurally equivalent, so you can use a Cursor<BR>> where a Window would be required etc. It looks like a bit of facelifting<BR>> to me.<BR>> <BR>> And if it's only for readability and proper naming, all those should<BR>> surely be named <x>Handle, shouldn't they?<BR>> <BR>> The same level of abstraction could be achieved by defining just one<BR>> XProtoHandle as unsigned_int, couldn't it?<BR>> <BR>> I think I just have never understood the usefulness of interfaces<BR>> too large to remember, but that may be a general problem with X...<BR>> <BR>> Olaf<BR>> -- <BR>> Olaf Wagner -- elego Software Solutions GmbH<BR>> Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany<BR>> phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95<BR>> http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin<BR>> Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194<BR>> <BR> </body>
</html>