[Lazarus] Is Lazarus project in a downward spiral?

Hans-Peter Diettrich DrDiettrich1 at aol.com
Mon Mar 8 12:59:53 CET 2010


JoshyFun schrieb:

> HPD> I already made an C-to-Pascal converter
> HPD> <http://sourceforge.net/projects/topas/>, but then got stuck in handling
> HPD> #defines, which deserve translation into either constants or functions,
> HPD> or must be expanded.
> HPD> I never wanted it to handle C++ syntax, but if you have ideas how to
> HPD> make it usable for (partial) translation of C++ code, I'm willing to
> HPD> update it accordingly.
> 
> I think that it would be great to have something that can sintax
> traslate from C++ to Pascal, but not a whole code with defines,
> macros, and other things, just a plain block syntax converter, that
> could simplify manual conversion, like creating the var block,
> handling the if {} conversion and always take the simple route, not
> trying to be smarter than the user ;)

IMO you don't know enough about the real problems. Even a C parser must 
know about type names, so that proper detection and handling of all 
typedefs is vital, what means that the implementation of an preprocessor 
is inevitable.


> Integrating this in the IDE could help to convert function by
> function, without too many changes.

This would be possible, but IMO a useful translator should be an 
interactive tool of its own. The source code could be analyzed and split 
into sections by such a tool, where some sections (declarations!) must 
be converted by the user, before the translator can do the stupid work 
of translating the code blocks inside subroutines. The user will have to 
spend much time in replacing the references to symbols in header files, 
and in writing stubs that call the RTL equivalents of the original C 
functions.

IMO the integration of an true C++ compiler, like CBuilder, would make 
FPC/Lazarus much more intersting and useful in real life, removing the 
need to translate existing (legacy or library[1]) C/C++ code. I don't 
know how far a mix of Pascal and C/C++ object code is already possible, 
based on the unified object file formats, but a direct interface to C 
code by using compiler-created library units were really great.

[1] The use of non-Pascal libraries would require another translation of 
the source code, after every bugfix or other changes. It's almost 
impossible to update *translated* code of other languages, instead the 
entire code must be translated into Pascal again, after every update of 
the external source code.

In an attempt to add compression modules to Abbrevia, I noticed an bug 
in the C code. When I reported that bug to the library maintainer, it 
turned out that just this bug had been fixed a few weeks ago, after the 
library existed and was used for many years! This was one of the reasons 
why I stopped my work on Abbrevia as a pure Delphi/Pascal-based project, 
in favor of 7zip, which uses the existing C libraries directly.

DoDi





More information about the Lazarus mailing list