[fpc-pascal]Synapse for FPC

Matt Emson memsom at interalpha.co.uk
Thu Jul 24 11:21:23 CEST 2003


> I would prefer a language that is tightly integrated with an OS... so
tightly
> that OS calls and language calls fit together in one smooth flow. I should
not
> have to translate strings or use trickery like "A := B+A+#0" or "@A[1]" to
get
> things to work. OS calls should be so seamless as to appear to be part of
the
> language, not part of yet another complex bag of tricks that has to be
studied
> and understood.

In most cases, casting an ansistring as pchar will work. The only caveat is
when Windows wants to alter the variable you pass' contenets.

e.g.
       MessageBox( pchar(MyMessage), 'test', MB_OK);

but not:

      GetUserName( pchar(Username), 255 );  //error!!!

instead:

var
  Username: array[0..255] or char;

begin
  GetUserName( Username, 255 );  //This works!!
end;

This, however, is how Delphi does it, so you may find that your mileage
varies. For example, the second GetUserName example my require an
'@Username' param.


> I'm not saying you should mask API calls to make them look like Pascal
syntax.
> Just the opposite, I'm thinking it might be better to bend Pascal to work
> better with the OS... Make it natively work with null terminated strings
in
> windows, give it the same numerical structures as BEOS, support LINUX file
> handling in Pascal's normal file handlers, etc.

Most OS have similar concepts; they just accomplish things in different ways
(e.g. Linux devices are all file descriptors, but BeOS devices are almost
all file descriptors, and Windows Devices are not.) Wrapping up the
differences is the smart way of making sure your skills are transferable.

Matt






More information about the fpc-pascal mailing list