Modern Pascal

StandardPascal? is dead. PascalLanguage is dead.

Modern Pascal is much much better, and supports modular programming, open arrays (not recoding functions for each new array with different bounds), ansistrings (no 255 braindead limit), linking with existing C code, safety features (pointer checks, range checking, etc) that one can even turn off, and much more.

Compilers that support a modern Pascal started with TurboPascal from Borland and ModulaLanguage from Wirth, and continued with DelphiLanguage and FreePascal; ModulaTwo, ModulaThree, OberonLanguage, and ComponentPascal. Many of the resulting libraries were looted by JavaLanguage.

Some argue that these modern pascals are "object pascals" but in fact they support both modular, procedural, and OOP style coding. This is why some make a point to call it "modern pascal" instead of "Object Pascal" or "Delphi Language".


Old braindead Standard Pascal was created in a very limited sense.. where one would add more and more procedures to the end of the file. This was partly modular in a sense that one could continue to add more subprograms... but it lacked modules or a unit system. Modern Pascals all support a module and unit system (at least one's worth their salt do).

Widely used Modern Pascals are compatible with each other (freepascal can compile delphi code, vice versa.. if in mode delphi).

Modern Pascal code is compatible with Cee when using for example Records to Structs (DLL's can be made and shared between languages). Even proof that ObjectiveCee can be compatible with Modern Pascal is lately surfacing with some programmers working on compatibility layers. Some work has been done to make modern pascals compatible with C++, not just Cee.

In Modern Pascal one can shoot himself in the foot, and is not meant for just academic use. Although there are many compiler options to turn on which significantly reduce shooting oneself, and there are many built in automated types that save a programmer from shooting himself in the foot. For example dynamic arrays unlike in C where pointers to pointers are common. Ansistrings, but an actual built in type.. not a class like in C++.

Open arrays (sending an array of any length into any function) are a great improvement over severely limited standard pascal.

A dynamic type is available in modern pascal called a variant.

Pointers are available but don't have to be used.

Parameters can be sent in by reference, by value, or as special out params.


There unfortunately are still some Standard Pascal advocates who JustDontGetIt and continue to assume that StandardPascal? is the way of the future.. about 5 of them on earth. Even NiklausWirth himself has moved away from Standard Pascal isms, creating languages such as Modula and Oberon. Standard Pascal was a good engineering and learning/discipline lesson.. but Modern Pascal is practical and used more in the real world.


An example of ModernPascal:

  program example;
  uses
    somemodule, sysutils, other;
  type 
    Tsomeclass = class
      // methods, properties, vars go here
    end;

type strarray = array of ansistring; shortstrarray = array of shortstring; str14array = array of string[15]; limitedarray = array [0..100] of ansistring;

var pc: pchar; // compatible with CeeLanguage *char s: ansistring; // ref counted string (no allocation or disposal required) i: integer; b: boolean; someclass: Tsomeclass;

begin s:= 'foo bar'; // string is unlimited, no 255 limit s:= s + 'more text'; writeln('Hello'); writeln(123, ' foo', ' bar ', 455+1); // call some function in a module sysutils.format(); // use a class someclass:= Tsomething.create; someclass.method(); someclass.free; // can cast an ansistring to a CeeLanguage char someapi(pchar(s)); end;


See also:


CategoryPascal


EditText of this page (last edited October 17, 2014) or FindPage with title or text search