Re: C library interface
- From: Andrew Haley <andrew29@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 06 Mar 2009 06:20:11 -0600
Stephen Pelc <stephenXXX@xxxxxxxxxxxx> wrote:
Bernd's excellent survey is really about implementation, but at the
moment I'm more worried about notation. There are currently three
models in use:
4 1 Function: PostMessage
Outside: PostMessage { hwnd mesg wparam lparam -- bool }
Extern: BOOL PostMessage(
HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
);
The Function: notation assumes that everything is a cell. It does
and always will fail on some systems, especially for floats and for
items less than a cell. Many variants assume that a single cell is
always returned.
The Outside: notation is not bad but throws away some information that
is useful for self-documenting code. Overall, the parsing requirements
are much the same as for the Extern: notation.
The Extern: notation throws least information away. It's basically
the same as the libcc approach (parse the C header) with a totally
different implementation approach.
But AFAICS libcc doesn't parse anything; the C compiler does.
To provide library portability we need to be able to define an alias
because the library code may use a different stack order.
LocalExtern: p_PostMessage BOOL PostMessage(
HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
);
To this we need to be able to specify the stack order, e.g. L>R or
R>L, the call type, e.g. "C" or "PASCAL" or WINAPI or FORTRAN
All of this is horribly nonportable. The stack order is declared in
the header file for the function, at least if you use the libcc
technique. There seems to be no reason to expose all this
implementation stuff for a standard reference implementation.
Andrew.
.
- Follow-Ups:
- Re: C library interface
- From: Bernd Paysan
- Re: C library interface
- References:
- Is Forth more focused on detail rather than on concept?
- From: Helmar
- Re: Is Forth more focused on detail rather than on concept?
- From: Stephen Pelc
- Re: Is Forth more focused on detail rather than on concept?
- From: Bernd Paysan
- Re: Is Forth more focused on detail rather than on concept?
- From: Stephen Pelc
- Re: Is Forth more focused on detail rather than on concept?
- From: Andrew Haley
- C library interface
- From: Stephen Pelc
- Is Forth more focused on detail rather than on concept?
- Prev by Date: Re: C library interface
- Next by Date: Re: Forth input line buffered, why?
- Previous by thread: Re: C library interface
- Next by thread: Re: C library interface
- Index(es):
Relevant Pages
|