-----Original Message----- From: Frank Heckenbach [mailto:ih8mj@fjf.gnu.de] Sent: 05 April 2005 12:23 To: gpc@gnu.de Subject: Re: Who uses Pascal? Part 2
Andrew Gregory wrote:
I think that Pascal is still one of the better compiled languages. For someone who wants to write GUI applications on Windows, Delphi is a good choice because of features such as the form designer. But things have moved on: Powerful dynamic scripting languages such as Python contain a lot of new thinking, and really do save time in many applications (e.g. data processing). There is a good case for writing core functions (e.g. maths) in a compiled standardised language such as Pascal or extended Pascal, which will be around for decades, then writing interfaces to scripting languages as required. Unfortunately, to interface Python and gpc, you have to go via C, so for new code it's tempting just to use C.
But what does "go via C" actually mean? I remember a joint project I did with a C++ programmer. We also "went via C" which means he wrote `extern "C"' and I wrote `external name' etc. No actual C code was involved (apart from the GMP library which is written in C (and assembler) and was used by both Pascal and C++ parts of the program). So "going via C" doesn't have to mean more than using a simple (i.e., only types available in C, no schemata, templates or objects etc.) and well-defined (no name-mangling) calling interface.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8
At the highest level Python is a "typeless" language - all of the parameters supplied to a function are references to objects of type PyObject (as Python is written in C I assume that a PyObject is a C struct although I've not looked into this in detail). A PyObject may contain a float, string, complex etc., or a sequence of references to other objects. Dynamic typing (i.e. type checking at run time rather than compile time) is a feature if Python.
Python library functions (prototypes in Python.h, binary library libpython24.a) such as PyComplex_AsCComplex for example must be called for type checking and for conversions to C types at run time. Correct me if I'm wrong, but as far as I know you cannot do that directly from Pascal without quite a lot of work to get Python.h and the many include files within into a Pascal-compatible form. Therefore you have to use C or C++.
If you declare a file of C externs for your Pascal procedures and functions, you can generate Python wrapper interface code automatically using SWIG (www.swig.org) although this is not always worthwhile.
I've interfaced several Pascal mathematical libraries to Python via C - it doesn't take that long and the results are excellent.
Andrew.
------------------------------------------------------------------- This e-mail and any attachments may contain confidential and/or privileged material; it is for the intended addressee(s) only. If you are not a named addressee, you must not use, retain or disclose such information.
NPL Management Ltd cannot guarantee that the e-mail or any attachments are free from viruses.
NPL Management Ltd. Registered in England and Wales. No: 2937881 Registered Office: Serco House, 16 Bartley Wood Business Park, Hook, Hampshire RG27 9UY United Kingdom -------------------------------------------------------------------