Next: , Previous: Miscellaneous, Up: Borland Pascal



7.22 BP and Extended Pascal

Pascal is a well-known programming language and hardly needs to be described here. Note, however, that there is a large difference between the language used by the BP compiler and the Pascal Standards.

Extended Pascal is a standardized language based on the original Standard Pascal, but with significant extensions. Unfortunately, Borland Pascal does not conform to any of the Pascal standards. Writing a program that both complies to Extended Pascal (or even Standard Pascal) and compiles with BP is almost impossible for any non-trivial task.

On the other hand, BP has some nice features that make it very powerful in the environments in which it runs. However, some of those features are of little use on non-Dos systems and would not be good candidates for standardization.

There are also several BP features which are semantically similar to features in Standard Pascal or Extended Pascal, but syntactically different.

Therefore, in order to be useful to users coming from either side, GPC supports both the standards and the BP dialect as good as possible. By default, GPC allows features from any dialect it knows. By giving a dialect option such as --borland-pascal or --extended-pascal, you can tell GPC to disable the features not found in that dialect, and to adjust its warning behaviour to the dialect.

The different sets of reserved words are a little problem, but GPC solves it by making the words in question only “conditionally reserved” which works transparently without problems in most cases. Still, giving a dialect option will disable all keywords not part of this dialect.

Apart from this, there are surprisingly few real conflicts between the dialects. Therefore, you can usually compile your BP code without the --borland-pascal option and make use of all of GPC's features. You might be surprised, though, when GPC accepts things you didn't know were allowed. :−)

Finally, if you want to make use of some of GPC's extensions (compared to BP) and still keep the code compileable with BP without using ifdefs all over the place, we suggest you look at the unit gpc-bp.pas, shipped with GPC, which contains BP versions of some of GPC's features. Please read the comments at the beginning of the unit to find out more about it.