GPC on Solaris 2.6

Peter Gerwinski peter at gerwinski.de
Tue Sep 14 19:54:13 CEST 1999


Tom Schneider wrote:
> > Yes, but it would leave them alone like the compiler stores them,
> > i.e. first letter capitalized, the rest lower-case. That might not
> > be what you want.
> 
> Definitely not!!  This is silly because file names are case sensitive in
> Unix.  Why not just leave the file names alone???????

Pascal is case insensitive according to the ISO standards and to
all the other de-facto standards I have heard of.  For this
reason it *must not* alter the behaviour of a program if you
change the case of a letter in the source (except in string
constants).

Since Unix file names are case sensitive and Pascal identifiers
are case insensitive, it is silly to construct a compiler that
maps Pascal identifiers to Unix file names without a
well-defined case mangling.  One can capitalize everything, or
only the first character, or put everything to lower case.
I think that the latter option is the most acceptable one.

BTW, how do other compilers handle file names with extensions?
How do I read a file `foo.dat' from a Pascal file when the file
name is derived from the identifiers in the program header?

> >It is planned to change this as soon as we've got
> > the qualified identifiers working (before that, doing so would cause
> > name space conflicts with libc).
> 
> I don't know what this means, but I'm puzzled why it is such a big deal.
> Names have scope in Pascal.  So why can't all names in the code have the
> scope of the code and then there should be no way that there would be name
> space conflicts?!  Why isn't this obvious to compiler writers?

These scopes are nothing that comes from itself; we have to
write them.  The linker has its name space.  If we do not want
our Pascal names to conflict with, say, the libc, we must feed
the linker with names that cannot conflict.  One way to do this
is capitalization of the first letter which is not done in most
C libraries.  A better way will be introduced together with
qualified identifiers, as Frank already pointed out.

> Thanks for the instructions on using patch (it's simple!) but I realized that
> it is not good way to go because a version I provide to people would be
> quickly out of date, or I would be forced to keep patching the latest version
> (and eventually the patch would not work of course).

We can introduce this patch into GPC as an option (as you
suggested initially), but it will put the file names to
lowercase (or do some other well-defined case mangling).
Leaving the case alone would violate the Pascal standards.

Is there really more than one compiler that derives the file
name - including the case - from the Pascal identifiers in the
header?  How do those compilers deal with file name extensions?

> (Do you really enjoy typing all the file names all the time??) 

No.  We use one of the mechanisms to specify the file name at
run-time from a string.

UCSD Pascal:

    reset ( MyFile, 'myfile.dat' );

Borland Pascal:

    assign ( MyFile, 'myfile.dat' );
    reset ( MyFile );
  
ISO Extended Pascal:

    Var
      MyFile: File of whatever;
      B: BindingType;

    unbind ( MyFile );
    B:= binding ( MyFile );
    B.Name:= 'myfile.dat';
    bind ( MyFile, B );
    reset ( MyFile );

All this works in GPC.

Greetings,

    Peter

-- 
Peter Gerwinski, Essen, Germany, http://home.pages.de/~Peter.Gerwinski/
Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118
  PGP key on request - 6C 94 45 BE 28 A4 96 - 0E CC E9 12 47 25 82 75
*** Vote against SPAM! ********* http://www.politik-digital.de/spam/ ***




More information about the Gpc mailing list