The purpose of GNU Pascal_(re)

Wed, 24 Jul 1996 01:52:23 +0200 (MET DST)


Hello Berend, hello GPC-list!

> > Furthermore, I could not write my real-world programs 
> > just with Extended Pascal; I need, for example, bit shift operators, GetMem, 
> > FreeMem, and Objects.
> 
> You don't need GetMem and FreeMem as I did show you :-) But you need the other
> two.

You can replace *some* applications of GetMem and FreeMem with Extended
Pascal schema types, but this is not reasonable for *all* applications.

For example in low-level programming you need to provide a buffer of a 
specified size in Bytes which you don't know at compile time.  This 
*can* be done with an Extended Pascal array schema

  Type
    ByteArray ( Size: Integer ) = 
      packed array [ 1..Size ] of __byte__ Integer;
    ByteArrayPtr = ^ByteArray;

  Var
    Buffer: ByteArrayPtr;
    n: Integer;  (* Size of Buffer *)

  [...]   (* Read or calculate n *)

  New ( Buffer, n );

  [...]

  Dispose ( Buffer );

but you have to pass the address of the Buffer -- not that of the schema
-- to the system call.  You may be able to work around this, but using
GetMem would be more appropriate in this context.

However, we *have* GetMem and FreeMem (and shl and shr) in GNU Pascal, 
and I won't take them out again. ;-)

> > and integrate them in one powerful compiler which will set up the next
> > standard. 
> 
> I certainly don't agree with this if the compiler does not have switches to
> accept only Extended Pascal or only ISO Pascal or only ...

... or only Borland Pascal. ;-)

Okay, we can implement those switches.  Actually, you already can specify
--pedantic, and GPC will complain about everything which is not ISO 7185.

> Programs conforming to the Extended Pascal will probably not only work in many
> different environments but also with many different compilers. I don't want to
> loose that feature/possibility. 

Nobody wants you to lose this feature.  But I don't want to lose the 
possibilities of Borland Pascal.  I will lose them if I wait for new
compilers by Borland, so I react.

By the way: Where are those many different Extended Pascal compilers?

> Extending a compiler with more features is not a problem, but IMO, one should
> complete the standard parts first.

Most of the features I am speaking of *are* already implemented into
GPC, so your statement is coming too late. :-) The discussion is about
how to modify GPC.GUIDE in order to take the existence of the extensions
into account.

Who is "one"?  If you want to do have the standard completed, why don't
you do it yourself?  However, I find the schema types interesting enough 
that I could do the implementation (but don't hold your breath).
Concerning the rest of the standard, I don't know what is missing.
Please tell me!

> Hmm, I don't think that Extended Pascal is not powerful enough. It's true that
> it does not contain everything one needs, but that's mainly due to the goal of
> creating a portable language.

I don't know the reason, but this can *not* be the reason.  You don't lose
portability by simply including bit-shift operators, objects, etc. into 
the Extended Pascal standard.  But they didn't include them.  No idea, why.

> And the new object standard also rectififies some omissions.

What are the advantages which rectify omissions?  I don't see anything
which rectifies *not* to have this-or-that in the standard except the
lazyness of those who have to implement the standard into a compiler.

> I can create everything I want in Extended Pascal programs with only a few
> routines accessing non-standard parts, mainly concerning bit-operators (you can
> do this with Extended Pascal, but it's a bit more tedious), and system call
> access (assembly).

You mean: "with Object Pascal extensions"?  Otherwise there is at least
one major feature missing.  And what about, say, user-defined operators
which are almost a *must* for scientific calculations?  As an example,
compare the line which applies three rotations to the matrix B

  B:= Rz ( phi ) * Ry ( theta ) * Rz ( - phi ) * B;

(copied from one of my scientific programs) with the construct

  CalculateRz ( - phi, Rtemp );
  MultMatrices ( B, Rtemp, B );
  CalculateRy ( theta, Rtemp );
  MultMatrices ( B, Rtemp, B );
  CalculateRz ( phi, Rtemp );
  MultMatrices ( B, Rtemp, B );

or, a little more compact,

  RotateZ ( B, - phi );
  RotateY ( B, theta );
  RotateZ ( B, phi );

The single line with matrix operators is almost the same as you would
write down on a piece of paper.  This is a *short* example.  Imagine
a program which contains a sequence of 50 such lines with and without
user-defined operators.  I have written such things with Borland Pascal,
and I included the lines with operators as comments just to have something
in the program you can still read.  Now I can use operators in GNU Pascal,
and my programs have become much smaller and easier to maintain.

> A compiler which accepts every Pascal standard and does everything would be nice
> of course. But there is quite some work to do. So I would like to add that we
> first focus on the ISO Pascal and Extended Pascal part. Even the ISO Pascal
> standard, according to Scott Moore (have email address if anyone wants it),
> needs much looking after.

I will first continue to focus on those extensions which I intend to use
myself, i.e. the rest of the Borland and PXSC extensions, plus Extended
Pascal schema types which are a reasonable extension (in my opinion).
If somebody wants to focus on the ISO Pascal standards, I offer my help
to get started with GPC-hacking.  But I don't intend to spend my time with
trying to satisfy standard specifications I don't realize their sense.

> Don't overlook the Pascal standards boys (no girls here I assume). 
> They do much more than you think, 

What are they doing?  I am sorry, but in the moment I don't see any
advantage of obeying the standards; I only see that I have to give up
some possibilities I am having now.  I admit that there are good ideas 
in Extended Pascal (e.g. structured return values, complex numbers,
schema types), but those Pascal standard boys did overlook the existing
Borland Pascal compiler and defined a standard below the requirements of
real-world programming.

> but different than Borland Pascal which has quite a C
> feeling and lost too much of it's real Pascal spirits.

This depends entirely on the programmer.  Borland took over good 
ideas from C, and GNU C took over good ideas from Pascal.  Why not?
How would you define "real Pascal spirit"?

And *why* did Borland do this?  Borland Pascal is based on UCSD Pascal
which was a well-defined standard.  But they went beyond UCSD in order
to meet the requirements of real-world programming, especially low-
level programming.  For many years, nobody took over Borland's ideas
and made a standard out of them, so it developped on an island, while
the rest of the world almost forgot Pascal completely and went to C
and C++.  Then they defined the Extended Pascal standard.  So why
did they ignore Borland's ideas which already had proven their use?
It would have been trivial to include, for example, bitwise AND and OR
and bit-shift operators into the standard.  If those who define the
standard overlook my needs, I take the right to overlook their standard
in the sense that I won't accept it as a restriction.  Of course, I am
profiting of good ideas such as structured return values, etc., but I
prefer a compiler which understands *more* than just the standard.

So again: What about changing the beginning of GPC.GUIDE in order to
take into account that GPC has some extensions, now?  I don't want
to say that GPC should not become ISO-10206-compliant, but I would
prefer to specify the goal to write the best possible Pascal compiler
rather than obeying a specific standard.  Extended Pascal may be good,
but GPC will be even better.  It is time to set up the next standard!

Yours,

    Peter


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es